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

[µo°Ý]¦p¦ó¨Ï¥ÎVBA±N¦³­«½Æ°Ñ·Ó­È¶K¨ì¤£¦Pworksheet

[µo°Ý]¦p¦ó¨Ï¥ÎVBA±N¦³­«½Æ°Ñ·Ó­È¶K¨ì¤£¦Pworksheet

¦U¦ì±M®a¦n¡A§Ú¦Û¤vªñ´Á¶}©l¦Û¤vÆp¬ãµ{¦¡¼¶¼g,
¥Ñ©ó¬OVBA·s¤â¡Aªñ¨Ó°t¦X¤u§@©Ò»Ý·Q­n¼g¤@­ÓVBAµ{¦¡¡A¬d¤Fºô¸ô¤W³\¦h¸ê®Æ¡A¥²¶·¸ó¤£¦Pªí³æ°Ñ·Óªº¤@­Ó§@·~
¥»·Q¨Ï¥Î¥¨¶°·f°tVlookup¨ç¼Æ¦ý¦]¬°¥L¨Ã¤£¬OCase sensitiveªº¨ç¼Æ¡A¦]¦¹§@½}

¹Á¸Õ¼g¤FIndex °Ñ·Óªí¦ýµo²{¤ñ¹ï·|°±¤£¤U¨Ó¡A§Ú·Q¸ò§Ú¤Uªº«ü¥O¦³Ãö
¹w´Á§Æ±æ«ö¤U«ö¶s(³z¹L"±a¤J¾¯à(right)"ªº«ö¶s,TriggerH2Äæ¦ìÅýªíA©³¤Uªº¯à±qªíBÄæ¦ìA¥H¤Î¨ä¬Û¦P¦C¸ê®Æ³£¯à¶×¤J¬Û¹ïÀ³ªº­È
¦p¹Ï:


¦ý«÷´êªº¥¨¶°³£·|Åܦ¨³o¼Ë...


³o¬O§Úªºµ{¦¡½X
  1. Sub «ö¶s9_Click()

  2. Dim SourceLastRow As Long
  3. Dim OutputLastRow As Long
  4. Dim sourceSheet As Worksheet
  5. Dim outputSheet As Worksheet




  6. 'What are the names of our worksheets?
  7. Set sourceSheet = Worksheets("competencylist_2016")
  8. Set outputSheet = Worksheets("inserttext")

  9. 'Determine last row of source
  10. With sourceSheet
  11.     SourceLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
  12. End With
  13. With outputSheet
  14.     'Determine last row in col P
  15.    OutputLastRow = .Cells(.Rows.Count, "P").End(xlUp).Row
  16.     'Apply our formula
  17.    
  18.   

  19.    .Range("B6:B20" & OutputLastRow).Formula = _
  20.         "=INDEX('competencylist_2016'!$C$2:$C$100, SMALL(INDEX(($H$2='competencylist_2016'!$A$2:$A$100)*(MATCH(ROW('competencylist_2016'!$A$2:$A$100),ROW('competencylist_2016'!$A$2:$A$100)))+($H$2<>'competencylist_2016'!$A$2:$A$100)*1048577,0,0),ROW('competencylist_2016'!A1)))"

  21.    .Range("C6:C20" & OutputLastRow).Formula = _
  22.        "=VLOOKUP(B:B,'" & sourceSheet.Name & "'!$C$1:$F$1" & SourceLastRow & ",2,0)"
  23. End With

  24. End Sub
½Æ»s¥N½X
±æ¦U¦ì¥ý¶iµ¹¤©«ü¾É¡AÁÂÁÂ!
VBA TEST08022016.rar (375.92 KB)

¦^´_ 1# s5512765
  1. Range("B6:B20" & OutputLastRow).Formula
  2.    .Range("C6:C20" & OutputLastRow).Formula =
½Æ»s¥N½X
¤u§@ªí¤W³]ªº¤½¦¡ ·í¾°È½s¸¹ ªºBBItem3,BItem4 ¤p©ó 20-6 ,©Ò®Mªº¤½¦¡, ·íµM¦³¿ù»~­È

¸Õ¸Õ¬Ý
  1. Option Explicit
  2. Sub «ö¶s9_Click()
  3.     Dim sourceSheet As Worksheet         '**  Åܼƫ¬ºA¬°¤u§@ªíª«¥ó
  4.     Dim outputSheet As Worksheet         '**  Åܼƫ¬ºA¬°¤u§@ªíª«¥ó
  5.     'What are the names of our worksheets?
  6.     Set sourceSheet = Worksheets("competencylist_2016")
  7.     Set outputSheet = Worksheets("inserttext")
  8.      outputSheet.Range("B6:I" & Rows.Count) = "" '**²M°£Â¦³ªº¸ê®Æ
  9.    
  10.     With sourceSheet
  11.              '**Count ÄÝ©Ê ¶Ç¦^¤@­Ó Long (ªø¾ã¼Æ)¡Aµ¥©ó¦b¤@­Ó¶°¦Xª«¥ó¤¤ªºª«¥ó¼Æ¥Ø¡C°ßŪ¡C
  12.              '** Columns.Count  -> ¤u§@ªíªº©Ò¦³Äæ¼Æ
  13.             
  14.              .Cells(1, Columns.Count - 3).Resize(, 4) = Array(.Range("A1"), "", .Range("C1"), .Range("D1"))
  15.               '** ¼g¤J¦r¦ê  BBItem1 ,"", BBItem3, BBItem4
  16.             
  17.              .Cells(2, Columns.Count - 3) = outputSheet.Range("H2")  '**¾°È½s¸¹
  18.             
  19.              '**¶i¶¥¿z¿ï
  20.              .Range("A1").CurrentRegion.AdvancedFilter xlFilterCopy, .Cells(1, Columns.Count - 3).Resize(2), .Cells(1, Columns.Count - 1).Resize(1, 2)
  21.             
  22.             '.Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=.Cells(1, Columns.Count - 3).Resize(2), CopyToRange:=.Cells(1, Columns.Count - 1).Resize(1, 2)
  23.              '** AdvancedFilter ½d³òªº¶i¶¥¿z¿ï , xlFilterCopy  ¿z¿ï¨ì¨ä¥L¦ì¸m
  24.              '**AdvancedFilter ¤èªk   °ò©ó·Ç«h½d³ò±q¸ê®Æ²M³æ¤¤¿z¿ï©Î½Æ»s¸ê®Æ¡C¦pªGªì©l¿ï©w¬°³æ­ÓÀx¦s®æ¡A«h¨Ï¥ÎÀx¦s®æ¥Ø«eªº°Ï°ìx¬°Variant¡C
  25.              '**  expression.AdvancedFilter(Action, CriteriaRange, CopyToRange, Unique)
  26.              '**expression      ¥²¿ï¡C¸Ó¹Bºâ¦¡·|¶Ç¦^ [®M¥Î©ó] ²M³æ¤¤ªº¨ä¤¤¤@­Óª«¥ó¡C
  27.               '**  Action     ¥²¿ïªº XlFilterAction ¸ê®ÆÃþ«¬¡C
  28.             '** XlFilterAction ¥i¥H¬O³o¨Ç XlFilterAction ±`¼Æ¤§¤@¡C xlFilterCopyxlFilterInPlace
  29.             '**CriteriaRange     ¿ï¾Ü©Êªº Variant¡C·Ç«h½d³ò¡C¦pªG¬Ù²¤¦¹¤Þ¼Æ«hµL·Ç«h¡C
  30.             '**CopyToRange     ¿ï¾Ü©Êªº Variant¡C¦pªG Action ¬° xlFilterCopy¡A¦¹¤Þ¼Æ«ü©w³Q½Æ»s¦Cªº¥Ø¼Ð½d³ò¡C§_«h©¿²¤¦¹¤Þ¼Æ¡C
  31.             '**Unique     ¿ï¾Ü©Êªº Variant¡C­Y¬° True¡A«h¶È¿z¿ï°ß¤@ªº°O¿ý¡F­Y¬° False¡A«h¿z¿ï¥X©Ò¦³²Å¦X·Ç«hªº°O¿ý¡C¹w³]­È¬° False¡C
  32.             
  33.             With .Cells(1, Columns.Count - 1).Resize(1, 2).CurrentRegion
  34.                 If .Rows.Count > 1 Then
  35.                     outputSheet.Range("B6").Resize(.Rows.Count - 1, 2) = .Rows("2:" & .Rows.Count).Value
  36.                     With outputSheet.Range("H6").Resize(.Rows.Count - 1, 2)
  37.                         .Columns(1) = "=RC[-2]-RC[-3]"         '¤½¦¡ : ¥Î R1C1¬Û¹ï¦ì¸m
  38.                         .Columns(2) = "=RC[-2]-RC[-4]"
  39.                     End With
  40.                 End If
  41.                 End With
  42.             .Cells(1, Columns.Count - 3).Resize(, 4).EntireColumn = ""  '½d³ò: ²M°£¦r¦ê
  43.     End With
  44. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¬°¤H³B¥@­n¤p¤ß²Ó¤ß¡A¦ý¤£­n¡u¤p¤ß²´¡v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD