请求大神帮忙写个excel VBA代码,谢谢!

2024-12-16 16:25:08
推荐回答(1个)
回答1:

法如下:

一、开发工具

二、双击sheet


三、建立事件

选择Change事件

四、编写代码

Private Sub Worksheet_Change(ByVal Target As Range)

Dim FRG As Range

If Target.Column = 2 Then

Set FRG = Sheet2.Range("B:B").Find(Target)

    If Not FRG Is Nothing Then

        Sheet1.Range("B" & Target.Row) = Sheet2.Range("B" & FRG.Row)

        Sheet1.Range("C" & Target.Row) = Sheet2.Range("C" & FRG.Row)

        Sheet1.Range("D" & Target.Row) = Sheet2.Range("D" & FRG.Row)

        Sheet1.Range("E" & Target.Row) = Sheet2.Range("E" & FRG.Row)

        Sheet1.Range("F" & Target.Row) = Sheet2.Range("F" & FRG.Row)

        Sheet1.Range("G" & Target.Row) = Sheet2.Range("G" & FRG.Row)

        Sheet1.Range("H" & Target.Row) = Sheet2.Range("H" & FRG.Row)

    End If

End If

End Sub

五、在分类1中输入金,后面数据自动出来