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

[µo°Ý] ½Ð±Ð¦p¦ó´M§ä»·ºÝºÏºÐ¤¤excelÀɮפu§@ªíµ²ªG

¦^´_ 3# chengtoo
¨S·j´M¥Xµ²ªG ·|¤@ª½¥X²{¿ù»~¦b ³Ì«á­±ªº End If  °õ¦æ«á¨S³o¿ù»~
¸Õ¸Õ¬Ý ­×§ï¬O§A©Ò»Ý¶Ü?
  1. Sub QuickSearch()
  2.     Dim wks As Excel.Worksheet
  3.     Dim rCell As Excel.Range
  4.     Dim szLookupVal As String
  5.     szLookupVal = InputBox("key in", "key in msg", "")
  6.     If szLookupVal = "" Then Exit Sub
  7.     Application.ScreenUpdating = False
  8.     'Application.DisplayAlerts = False
  9.     On Error GoTo Sheet_add        'µ{¦¡½X¦³¿ù»~:GoTo(¨ì) Sheet_add Ä~Äò°õ¦æµ{¦¡½X
  10.     With Sheets("Result").Cells    '¤u§@ªí¤£¦s¦b·|¦³¿ù»~
  11.         .Clear
  12.         .Cells(1) = "¤U­±¤]¦³©Ò»Ý­n¸ê°T" & szLookupVal
  13.         .EntireColumn.AutoFit
  14.         .HorizontalAlignment = xlCenter
  15.     End With
  16.     On Error GoTo 0                 'µ{¦¡½X¦³¿ù»~:¤£³B¸Ì->¹w¨¾¦³¤£ª¾ªº¿ù»~¥i¦A­×¥¿µ{¦¡½X
  17.     i = 2
  18.     For Each wks In ActiveWorkbook.Worksheets
  19.         If wks.Name = "Result" Then Exit For
  20.         With wks.Cells
  21.             Set rCell = .Find(szLookupVal, , , xlWhole, xlByColumns, xlNext, False)
  22.             If Not rCell Is Nothing Then
  23.                 szFirst = rCell.Address
  24.                 Do
  25.                     With Sheets("Result")
  26.                         .Cells(i, 1) = wks.Name & "'!" & rCell.Address
  27.                         .Cells(i, 2) = rCell
  28.                     End With
  29.                     rCell.Interior.ColorIndex = 19
  30.                     Set rCell = .FindNext(rCell)
  31.                     i = i + 1
  32.                 Loop While Not rCell Is Nothing And rCell.Address <> szFirst
  33.             End If
  34.         End With
  35.     Next wks
  36.     Set rCell = Nothing
  37.     Sheets("Result").Activate
  38.     If i = 2 Then MsgBox "©Ò­n¬d§äªº­È{" & szLookupVal & "}¦b¤u§@ªí¤¤¨S¦³", 64, "§ä¤£¨ì³á"
  39.     Application.ScreenUpdating = True
  40.    ' Application.DisplayAlerts = True
  41.    Exit Sub    'Â÷¶}µ{§Ç-> ¤£¦A°õ¦æ  Sheet_add:¤Uªºµ{¦¡½X
  42. Sheet_add:  'Result¤£¦s¦b®É·s¼W¤u§@ªí
  43.     Sheets.Add ActiveSheet
  44.     ActiveSheet.Name = "Result"
  45.     Resume       '¦^¨ìµ{¦¡½X¿ù»~¦æÄ~Äò°õ¦æµ{¦¡
  46. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 5# chengtoo
¹ï©ó¤£¤F¸ÑªºVBA ¨ç¼Æ,¤èªkÄÝ©Ê ,¦h¬Ý»¡©ú·|¶i¨Bªº
  1.       '.....µ{¦¡½X     
  2.      Set rCell = Nothing
  3.     Sheets("Result").Activate
  4.     If i = 2 Then
  5.         Application.DisplayAlerts = False    '°±¤î:¨tªº²Î¸ß°Ýµøµ¡
  6.         MsgBox "©Ò­n¬d§äªº­È{" & szLookupVal & "}¦b¤u§@ªí¤¤¨S¦³", 64, "§ä¤£¨ì³á"
  7.         Sheets("Result").Delete
  8.         Application.DisplayAlerts = True   '«ì´_:¨t²Îªº¸ß°Ýµøµ¡
  9.     End If
  10.     Application.ScreenUpdating = True
  11.    '.....µ{¦¡½X
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¤£­nÀH¤ß©Ò±ý¡A­nÀH¤ß±Ð¨|¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD