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

[µo°Ý] ½Ð°Ý¦U¦ì«e½úÃö©óFind »P¤ñ¹ïRange °ÝÃD

¥»©«³Ì«á¥Ñ ii31sakura ©ó 2014-8-16 14:51 ½s¿è

¦^´_ 6# GBKEE

¤£¦n·N«ä¡BGBKEE«e½ú½Ð°Ý¤@¤U¦]¤p§Ì¨Ï¥Î½d¨Ò(ex1)¥i¥H¥¿½T§ä¨ì·Q­nªºµª®×(¤ñ¹ïdata³Ì«áA&B ¨â­ÓÀx¦s®æ¦b©ó¨Ó·½dataÄÝ©ó­þ­Órow)¡A
¦ý¦]¤p§Ì±N½d¨Ò¥Î©ódataµ§¼Æ¯}¸U®Éµo²{°õ¦æ¸û¤[¡A
¬G·Q½Ð°Ý¬O¤£¬O¦³¹³(ex2)ªºFind¤è¦¡¥i¥H´M§ä¥¿½Tªºµª®×row¦b¦ó³B©O©Î¬O½Ð°Ý(ex1)¥i«üÂI¦p¦ó­×§ï©O¡H¡H

µù¡G
¦]ex2¤¤¤p§Ì¨Ï¥Î Union±N¨Ó·½data»Ý¤ñ¸ûªº¨âÄæ©ñ¤@°_·Q¥ÎFind§ä¨â­Ó±ø¥ó¡A¦ý¹ê»Ú¤WÁÙ¬OµLªk¹ê²{§Ú·Q­nªºµª®×(¦pex1©Ò¯à¥¿½Tªº§ä¥X²Ä´X¦C)¡B
¯à¤£¯àÀµ½ÐÀ°¦£¤@¤U~
   
find »P¤ñ¹ïRange °ÝÃD1.zip (18.04 KB)

Sub ex2()
    Dim range1 As Range, range2 As Range, range3 As Range, range4 As Range
    Dim allrange As Range, allrange1 As Range, c As Integer

   
b = Worksheets("¤ñ¹ïdata").[b65536].End(3).Row
c = Worksheets("¨Ó·½data").[b65536].End(3).Row
   
Set range1 = Sheets("¨Ó·½data").Range("A" & 2 & ":" & "A" & c)
Set range2 = Sheets("¨Ó·½data").Range("b" & 2 & ":" & "b" & c)
Set allrange = Union(range1, range2)



          '¦¹°Ï¶ô¬°¥ý§ärow
         Set findvalue = allrange.Find(What:=Worksheets("¤ñ¹ïdata").Cells(b, 2))  '¡ö¦¹ºØ¥u¯à§ä´M³æ¤@Àx¦s®æ¡A½Ð°Ý¬O§_¯à¹ê²{¤U¤@¬q³Æµù±¡ªp¡A¥i¥H§ä¨â±ø¥ó©O¡H
'Set findvalue = allrange.Find(What:=Worksheets("¤ñ¹ïdata").Cells(b, 1) & Worksheets("¤ñ¹ïdata").Cells(b, 2)) '°ÝÃDÂI(¦³¤èªk¥i¥¿½T¨Ï¨â­ÓÀx¦s®æªº±ø¥ó³£¥i§ä¨ì¶Ü¡H¦¹¬q½Ð°Ý¯à§_«üÂI¤p§Ì¸Ó¦p¦ó­×§ï©O¡H)
          MsgBox findvalue.Row


    Set range1 = Nothing: Set range2 = Nothing: Set allrange = Nothing: Set findvalue = Nothing



End Sub

TOP

¦^´_ 6# ii31sakura
­×§ï¬° R => ¥ÑAÄæ³Ì©³³¡©¹¤W¨ì¦³¸ê®ÆÀx¦s®æªº¦C¸¹
  1. 'Ar = Sheets("¨Ó·½data").Range("A1:D5").Value  'sheet"¨Ó·½data"¤¤("A~D")
  2.         With Sheets("¨Ó·½data")
  3.             R = .Cells(.Rows.Count, "a").End(xlUp).Row
  4.             Ar = .Range("A1:D" & R).Value 'sheet"¨Ó·½data"¤¤("A~D")
  5.         End With
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 4# GBKEE

¤£¦n·N«ä¡BGBKEE«e½ú¥i§_¦A½Ð«ü¾É¤@¤U¡A
¦pªG¨Ó·½data¸ê®Æ¦C¦ì¶W¹L¤ñ¹ïdata¦C¦ì¡B½Ð°Ý¥i±q­þÃä­×§ï_¥i¤ñ¹ï¨Ó·½data¨ì³Ì«á©O¡H

µù¡G¤p§Ì¦³±Nªþ¥ó¤º®e­×§ï¤@¤U(¤ñ¹ïdata¥u¨ì²Ä5¦C¡B¨Ó·½data¨ì²Ä5¦C¤§«á´NµLªk¶i¦æ¤ñ¹ï°Ê§@)
   
¥i§_½Ð³Â·Ð¤@¤U~
find »P¤ñ¹ïRange «á±NÄæ¦ìcopy¨ì¬YÄæ .rar (18.02 KB)

TOP

¦^´_ 3# ii31sakura
  1. Sub Ex()
  2.     Dim Ar(), i As Integer, S As String, Rng As Range, ss
  3.     With Sheets("¤ñ¹ïdata").Range("A" & Sheets("¤ñ¹ïdata").Rows.Count).End(xlUp).Resize(, 4)
  4.         S = Join(Application.Transpose(Application.Transpose(.Value)), "")
  5.         '"¤ñ¹ïdata"³Ì«á¤@µ§ªº("A~D")ªº¸ê®Æ
  6.     End With
  7.     With Sheets("Á`¾ã²z")
  8.         .Cells.Clear
  9.         .Range("A1").Resize(, 7) = Sheets("¨Ó·½data").Range("A1").Resize(, 7).Value     'ªíÀY
  10.         Ar = Sheets("¨Ó·½data").Range("A1:D5").Value  'sheet"¨Ó·½data"¤¤("A~D")
  11.         For i = 1 To UBound(Ar)
  12.             If S = Join(Application.Index(Ar, i), "") Then
  13.                 Set Rng = Sheets("¨Ó·½data").Cells(i, "A").Resize(, 7)
  14.                 MsgBox "¦b ²Ä" & i & " ¦C  §ä¨ì " & Join(Application.Transpose(Application.Transpose(Rng.Value)), ",")
  15.                 .Range("A" & .Rows.Count).End(xlUp).Offset(1).Resize(, 7) = Rng.Value
  16.             End If
  17.         Next
  18.     End With
  19. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 2# GBKEE

·PÁÂGBKEE«e½ú~¤£¦n·N«ä¦A½Ð°Ý¤@¤U¡B¤p§Ì¦pªG·Qª¾¹D§¹¥þ¬Û²Åªº(¨Ó·½data)¬O²Ä´XÄæ¦ì¡A
¦pªGª½±µ¿é¤J(msgbox s) «h·|Åã¥Ü{("A~D")ªº¸ê®Æ}¤º®e¡B¦pªG¿é¤J(msgbox s.address ©Î msgbox s row)³£Åã¥Ü"¤£¥¿½Tªº©w¦ì¶µ¡A
½Ð°Ý¤p§Ì¸Ó¿é¤J¨Ç¤°»ò©O¡H

TOP

¦^´_ 1# ii31sakura
¸Õ¸Õ¬Ý
  1. Sub Ex()
  2.     Dim Ar(), i As Integer, S As String
  3.     With Sheets("¤ñ¹ïdata").Range("A" & Sheets("¤ñ¹ïdata").Rows.Count).End(xlUp).Resize(, 4)
  4.         S = Join(Application.Transpose(Application.Transpose(.Value)), "")
  5.         '"¤ñ¹ïdata"³Ì«á¤@µ§ªº("A~D")ªº¸ê®Æ
  6.     End With
  7.     With Sheets("Á`¾ã²z")
  8.         .Cells.Clear
  9.         .Range("A1").Resize(, 7) = Sheets("¨Ó·½data").Range("A1").Resize(, 7).Value     'ªíÀY
  10.         Ar = Sheets("¨Ó·½data").Range("A1:D5").Value  'sheet"¨Ó·½data"¤¤("A~D")
  11.         For i = 1 To UBound(Ar)
  12.             If S = Join(Application.Index(Ar, i), "") Then
  13.                 .Range("A" & .Rows.Count).End(xlUp).Offset(1).Resize(, 7) = _
  14.                     Sheets("¨Ó·½data").Cells(i, "A").Resize(, 7).Value
  15.             End If
  16.         Next
  17.     End With
  18. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¨ü¤HÂI¤ô¤§®¦¡A¶··í´é¬u¥H³ø¡C
ªð¦^¦Cªí ¤W¤@¥DÃD