給你一個工作表事件程式碼,你可以參考使用:Private Sub Worksheet_Change(ByVal Target As Range)Application.ScreenUpdating = FalseOn Error Resume NextDim a As String, b As String, x As Integer, y As IntegerDim rng As Rangey = Sheets(3).[a65536].End(3).RowIf Target <> "" And Target.Column = 1 Then a = "*" & Target & "*" With Sheets(2) For Each rng In .UsedRange If rng Like a = True Then x = rng.Row y = y + 1 .Range(x & ":" & x).Copy Destination:=Sheets(3).Range("A" & y) End If Next End WithEnd IfApplication.ScreenUpdating = TrueEnd Sub這個程式碼的功能是在表1的A列輸入數值,自動查詢表二中對應A列數值然後事先複製到表三。
給你一個工作表事件程式碼,你可以參考使用:Private Sub Worksheet_Change(ByVal Target As Range)Application.ScreenUpdating = FalseOn Error Resume NextDim a As String, b As String, x As Integer, y As IntegerDim rng As Rangey = Sheets(3).[a65536].End(3).RowIf Target <> "" And Target.Column = 1 Then a = "*" & Target & "*" With Sheets(2) For Each rng In .UsedRange If rng Like a = True Then x = rng.Row y = y + 1 .Range(x & ":" & x).Copy Destination:=Sheets(3).Range("A" & y) End If Next End WithEnd IfApplication.ScreenUpdating = TrueEnd Sub這個程式碼的功能是在表1的A列輸入數值,自動查詢表二中對應A列數值然後事先複製到表三。