ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

excel vba ¬d§ä

¥»©«³Ì«á¥Ñ lpk187 ©ó 2016-10-18 10:55 ½s¿è

¦^´_ 3# markbaseball

¤£¦n·N«ä¡I§Ú¤£À´§Aªº¦~¥÷´`Àô¬O¤°»ò·N«ä¡A©µÄò¶Ü¡H
§Ú¥ý°²³]¬O©µÄò¦n¤F¡A¤W­zµ{§ÇªºSet c = AA.Rows(1).Find(rng.Offset(, 1), LookIn:=xlFormulas)
´N¬O¬d§ä¦~¥÷¡A¥u­n¬O§Aªº¦~¥÷³£©ñ¦b²Ä¤@¦C(¾ã¦C)¡A³£¥i¥H§ä¨ì¡C¦pªG¦~¥÷©ñ¦b²Ä¤G¦C¡A«h AA.Rows(1)§ï¦¨ AA.Rows(2)¡A¨Ì¦¹Ãþ±À
§Aªº°ÝÃD¤¤¦³2­Ó±ø¥ó¡A¤@­Ó¬O§ä¦~¥÷¡A¤@­Ó¬O§ä¥N¸¹¡A¦~¥÷¬O§ä²Ä¤@¦C(¾ã¦C)¡A¥N¸¹«h¬O§äAÄæ(¾ãÄæ)

­Y¤´¦³°ÝÃD¡A«Øij¤W¶ÇÀÉ®×

TOP

¦^´_ 2# lpk187


    ½Ð°Ý¤@¤U¡A§Ú¤u§@ªí1ªº¦~¥÷¨ä¹ê¬O´`Àôªº¡A¦]¬°¤£¥u¤@ºØ¸ê®Æ»Ý­n¬d§ä¡C
    ¨Ò¦p»¡:  2010 2012 2013 2014 2015 2010 2012 2013 2014 2015 ¤@ª½´`Àô¤U¥h¡C³o¼Ëªº¸Ü¡A¬d¸ßrow¸Ó«ç»ò­×§ï©O?

TOP

¥»©«³Ì«á¥Ñ lpk187 ©ó 2016-10-17 11:01 ½s¿è

¦^´_ 1# markbaseball
µ½¥Î°Ï°ìÅܼƵøµ¡¥H¤ÎF8(³v¨B°õ¦æ)¨ÓÆ[¬Ý§Aªº¥N½X¡A´N®e©ö§ì¨ì°ÝÃD©Ò¦b¤F
  1. Sub ro()
  2.     Dim ro As Integer
  3.     Dim AA As Worksheet
  4.     Dim rng As Range, r As Range, c As Range
  5.     Set AA = Worksheets("¤u§@ªí1")
  6.     With Sheets("¤u§@ªí2") '¥H¤u§@ªí2°µ¥Ø¼Ð°Ï°ì
  7.         ro = .[A65535].End(xlUp).Row '´M§äAÄ檺³Ì«á¤@®æªº¦C¸¹
  8.         For Each rng In .Range("a1:a" & ro) '¥HA1:A(roªº¼Æ­È)¬°½d³ò°µ´`Àô
  9.             Set r = AA.Columns(1).Find(rng, LookIn:=xlFormulas) '¦b¤u§@ªí1ªºAÄæ(Columns(1))¡A´M§ä¥N¸¹
  10.             Set c = AA.Rows(1).Find(rng.Offset(, 1), LookIn:=xlFormulas) '¦b¤u§@ªí1ªº²Ä¤@¦C(Rows(1))¡A´M§ä¦~¥÷
  11.             If Not r Is Nothing And Not c Is Nothing Then '¥N¸¹©M¦~¥÷³£§ä¨ì¤~°õ¦æ
  12.                 rng.Offset(, 2) = AA.Cells(r.Row, c.Column) '§â§ä¨ìªº®y¼Ð¤Wªº­È¶K¨ì rng(AÄæ) «áªº²Ä¤GÄæ(CÄæ)
  13.             End If
  14.             Set r =Nothing
  15.             Set c=Nothing
  16.         Next
  17.     End With
  18. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¹D¼w¬O´£ª@¦Û§Úªº©ú¿O¡A¤£¸Ó¬O¨þ¥¸§O¤HªºÃ@¤l¡C
ªð¦^¦Cªí ¤W¤@¥DÃD