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

[µo°Ý] À°¦£¸ÑÄÀ³o­Ó¼Ò½k¤ñ¹ï½d¨ÒÀÉ

¦^´_ 1# jesscc


       ­è­è¤~¬Ý¨ì¦¹¤å³¹...

µy·L¬Ý¤F¤@¤UªþÀÉ..  ¦b ¼Ò²Õªº t20110308a01 ªº¤º®e¨ºÃä ´N¤w¸g¦³»¡©úÀÉ®×..
¥H¤U¬OÂ^¨ú¸Ó¤º®e
'¡Õ¦p¦ó¦b EXCEL ¤¤¥H "¼Ò½k¤ñ¹ï" ¨ú±o¬Û¹ïÀ³ªº¸ê®Æ¡Ö
'¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð
'¡½¤ñ¹ï¨Ó·½¸ê®ÆÁö¦³¨ä²Î¤@¤Î¿W¥ß©Ê½è¡A¦ý­n³Q¤ñ¹ïªº¸ê®Æ§e²{¤£³W«h§ÎºA¡A
   'ª©¤j §Æ±æ¥ÎÃþ¦ü LIKE ªº¤è¦¡¤ñ¹ï B LIKE A¡A
   '¦ý¤S ¤£·Q¥Î VBA ¨Ó¨Ï¥Î¦^°é³v­Ó§PÂ_¡AÁקKªá¶O®É¶¡¹Lªø¡A
   '¬O¦]¬°³o°ÝÃD¤£¾A¥Î LIKE ¨Ó³B²z¡A­Y¨Ì¦¹¼Ò¦¡¡A¥²¥ý¨ú¥X¤@¨Ó·½­È¡A¦A°j°é
   '³v¤@§PÂ_³Q¤ñ¹ï­È¡A¥ç§Y¦pªG¨Ó·½­È¦³ 100 ­Ó¡A³Q¤ñ¹ï­È¦³ 1,000 ­Ó¡A«h¶·
   '°j°é 100*1,000 ¦¸¡A·íµM¥¢¨ä®Ä¯q¡C
'¡½ÁÙ¦n¡A¦³ EXCEL ªº¡e¨ú¥N¡f¥\¯à¥i¨Ï¥Î¡A¯à¦³®Ä¦a³B²z³o°ÝÃD¡A¨ä¤èªk¬°¡G
   '±N¥þ³¡¡e³Q¤ñ¹ï­È¡f½Æ»s¦Ü¨ä¡e¬Û¹ï¦ì¸m¡fªº»²§UÄ椤¡A¦A³v¤@¥H¡e¨Ó·½­È¡f
   '¤ñ¹ï¡A¨ú¥N¬°±ý¨ú±oªº¡e¹ïÀ³­È¡f¡A§¹¦¨«á±N»²§UÄ檺µ²ªG¥N¤J¥Øªº°Ï¶ô¤¤¡C
   '¦¹¤è¦¡¡A¶È¥Î¨ì¨Ó·½­Èªº°j°é 100 ¦¸¡Aµ´¹ï¤ñ¤½¦¡¨Ó±o§Ö¦h¤F¡C
'¡½µM¦Ó¬J¬O¡e¼Ò½k¤ñ¹ï¡f¥[¡e¨ú¥N¡f¡A·Ç½T²vÃø«O¦Ê¤À¦Ê¡A¦b¦r¦ê¨ú¥Nªº¶¶§Ç
   '¤W­n¥H¸û¦h¦rªº¥ý¨ú¥N , ¨Ò¦p:
   'À³¥ý¨ú¥N¡e¤¤µØ¹q³q¡f¡A¦A¨ú¥N¡e¤¤µØ¹q¡f¡A¦A¨ú¥N¡e¤¤µØ¡f¡eµØ¹q¡f¡C
'¡½¤ñ¹ï¡e¨Ó·½­È¡f¤£¥i»P­n¨ú±oªºµ²ªG¡e¹ïÀ³­È¡f¦³¬Û¦P¦r¤¸¡A¥H§KÂù­«¨ú¥N¡C
'¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð¡Ð

¤£¾å±o¼Ó¥D­nªº¬O«ç¼Ëªº®ÄªG
¥ú§â§O¤HªºÀÉ®×¥á¤W¨ÓµM«á»¡­n§ï ¤]¨S»¡­n§ï¤°»òµ²ªG
»¡¯uªº «ÜÃøÅý¤HÀ°±z ´N¹³¤W­±¤j¤j­Ì»¡ªº
¬Û¦P®ÄªG(µ²§½) ´N¦³¤£¦P¤è¦¡¥i¥H¥h°µ¸Ñ¨M
´N¦n¤ñ ±q¥x¥_­n¨ì«ÌªF  ´N¦³¦n´XºØ¤èªk¥i¥H¿ï¾Ü (®ü ³° ªÅ)
¦pªG ¿ï ®ü  ¨º ¤S¦³¤À §Ö ºC
¦pªG ¿ï ³° ¤S¦³¤À ¿¤¹D ¬Ù¹D ©Î °ª³t

¥H¤U¬Oµy·L§ó°Êªºµ{¦¡(§t§ó°Êªº¨Ç³\»¡©ú)
¦b¼Ò²Õªº T20110308a01 µ{¦¡¤U

Dim MyBook As Workbook, ShtA As Worksheet, ShtB As Worksheet, HeadA As Range, HeadB As Range, _
    RowsA As Long, RowsB As Long, bClmn(1 To 4) As Range, Ax(1 To 2), i, j  'bclmn(1 to N)   N= sheet1 ªº ¼Æ¶qªí¥Ü ¦p ¨ú®ø= 4

Sub ¦@¥Î°Ñ·Ó()
Set MyBook = ThisWorkbook
Set ShtA = MyBook.Sheets("Sheet1")
Set HeadA = ShtA.Range("A1")
With HeadA: RowsA = .Cells(65536 - .Row + 1, 1).End(xlUp).Row - .Row: End With
'-----------------------------------
Set ShtB = MyBook.Sheets("Sheet2")
Set HeadB = ShtB.Range("A1")
With HeadB: RowsB = .Cells(65536 - .Row + 1, 1).End(xlUp).Row - .Row: End With
End Sub

Sub ¶×¤J()
Call ¦@¥Î°Ñ·Ó
If RowsA <= 0 Then MsgBox "¡°¶×¤J¨Ó·½µL¶µ¥Ø¸ê®Æ!¡@¡@", 0 + 16: Exit Sub
If RowsB <= 0 Then MsgBox "¡°¶×¤J¥Ø¼ÐµL¶µ¥Ø¸ê®Æ!¡@¡@", 0 + 16: Exit Sub
Application.ScreenUpdating = False
'-----------------------------------------
Set bClmn(1) = Range(HeadB.Cells(2, 1), HeadB.Cells(RowsB + 1, 1))
Set bClmn(2) = Range(HeadB.Cells(2, 2), HeadB.Cells(RowsB + 1, 2))
Set bClmn(3) = Range(HeadB.Cells(2, 30), HeadB.Cells(RowsB + 1, 30))
Set bClmn(4) = Range(HeadB.Cells(2, 30), HeadB.Cells(RowsB + 1, 30)) 'set bclmn(N)   N= sheet1 ªº ¼Æ¶qªí¥Ü ¦p ¨ú®ø= 4 ¦p±ý¼W¥[¸Ó¼Æ¶qªí¥Ü «h¥²¶··s¼W1¦C

'-------------------------------------------
bClmn(3).Value = bClmn(1).Value
bClmn(2).FormulaR1C1 = "=IF(RC[28]=RC[-1],"""",RC[28])"
For i = 2 To RowsA + 1
    Ax(1) = HeadA.Cells(i, 1).Value
    Ax(2) = HeadA.Cells(i, 2).Value
    If Ax(1) <> "" And Ax(2) <> "" Then
       bClmn(3).Replace "*" & Ax(1) & "*", Ax(2), Lookat:=xlPart
    End If
Next i
'-----------------------------------------
bClmn(2).Value = bClmn(2).Value
bClmn(3).ClearContents
Beep
End Sub

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2011-5-9 09:05 ½s¿è

ªþÀɪºª`¸Ñ: ¦ý¤S ¤£·Q¥Î VBA ¨Ó¨Ï¥Î¦^°é³v­Ó§PÂ_¡AÁקKªá¶O®É¶¡¹Lªø¡A
¥i¬O ³B²z¸ê®Æ ¬OÁקK¤£¤F­n¥Î¨ì °j°éªº
ªþÀɪºµ{¦¡ ¥i­×§ï¦p¤U
  1. Sub Ex()
  2.     Dim Rng(1 To 2) As Range, R As Range
  3.     With Sheets("Sheet1")
  4.         Set Rng(1) = .Range(.[A2], .[A2].End(xlDown))   '³]©w¤ñ¹ïªºÄæ¦ì½d³ò
  5.         If Application.CountA(Rng(1)) = 0 Then Exit Sub  '¤ñ¹ïªº½d³ò¨S¸ê®Æ  Â÷¶}µ{¦¡
  6.     End With
  7.     With Sheets("Sheet2")
  8.         Set Rng(2) = .Range(.[A2], .[A2].End(xlDown))   '³]©wÅܧóªºÄæ¦ì½d³ò
  9.         If Application.CountA(Rng(2)) = 0 Then Exit Sub 'Åܧ󪺽d³ò¨S¸ê®Æ  Â÷¶}µ{¦¡
  10.         Rng(2).Offset(, 100) = Rng(2).Value             'Rng(2)¦ì²¾100Äæ¦ì¸mªº­È=Rng(2)ªº­È
  11.         Rng(2).Offset(, 1).FormulaR1C1 = "=IF(RC[99]=RC[-1],"""",RC[99])" 'Rng(2)¦ì²¾1Äæ¦ì¸mªº¼g¤U¤½¦¡
  12.     End With
  13.     For Each R In Rng(1)    '¨Ì§Ç³B¸Ì ¤ñ¹ï½d³òªºÀx¦s®æ
  14.         If R(1, 2) <> "" Then Rng(2).Offset(, 100).Replace "*" & R & "*", R(1, 2), Lookat:=xlPart
  15.         'Rng(2).Offset(, 100)¤¤ ¦³¥]§t RªºÀx¦s®æ §ó´«(Replace)¬°R(1, 2) [R¦ì²¾1Äæ]ªº¦r¦ê
  16.     Next
  17.     Rng(2).Offset(, 1).Value = Rng(2).Offset(, 1).Value
  18.     'Rng(2).Offset(, 1)ªº­È=Rng(2).Offset(, 1)ªº­È  'Rng(2).Offset(, 1)­ì¥»¬O¤½¦¡
  19.     Rng(2).Offset(, 100).Clear  '²M°£
  20. End Sub
½Æ»s¥N½X

TOP

Sub test()
Dim a, b As Range, i%, j%, arr
a = Sheet1.Range(Sheet1.[a2], Sheet1.[b65536].End(3))
With Sheet2
Set b = .Range(.[a2], .[a65536].End(3))
For i = 1 To UBound(a)
arr = Filter(Application.Transpose(b), a(i, 1))
For j = 0 To UBound(arr)
b.Find(arr(j))(1, 2) = a(i, 2)
Next
Next
End With
End Sub
¬Û¦Pªº¥Øªº¡A¼gªk¦ó¤î¤d¦Ê¡A³o¼Ë¬O§_¸û©ö©ó²z¸Ñ¡H

TOP

¤£¦n·N«ä¡A¦]¬°³o­Ó½d¨ÒÀÉ©M§Ú¥Ø«e­n°µªº¤u§@´X¥G¨SÔ£®t§O¡A©Ò¥H¤~·|®³¨Ó½Ð±Ð¦U¦ì¡C
Jess

TOP

«Øij§A´£¥X¦Û¤vªº°ÝÃD
®³¥X§O¤Hªº½d¨Ò¤S¤£¾A¦X§A¥Î
¦Ó¥B­n§@ªÌ¦Û¤v¤~¯à¸ÑÄÀ¥Lªº«ä¸ô
§Ú¬O¬Ý¤£©ú¥Õ¥L¬°¤°»ò­n³o¼Ë¼g

TOP

        ÀR«ä¦Û¦b : ¡i¥Í©R¦b©I§l¶¡¡j¦òªû»¡¡G¡u¥Í©R¦b©I§l¶¡¡C¡v¤HµLªkºÞ¦í¦Û¤vªº¥Í©R¡A§óµLªk¾×¦í¦º´Á¡AÅý¦Û¤v¥Ã¦í¤H¶¡¡C¬JµM¥Í©R¥h¨Ó³o»òµL±`¡A§Ú­Ì§óÀ³¸Ó¦n¦n¦a·R±¤¥¦¡B§Q¥Î¥¦¡B¥R¹ê¥¦¡AÅý³oµL±`¡BÄ_¶Qªº¥Í©R¡A´²µo¥¦¯uµ½¬üªº¥ú½÷¡A¬M·Ó¥X¥Í©R¯u¥¿ªº»ù­È¡C
ªð¦^¦Cªí ¤W¤@¥DÃD