将条件语句增加两行即可:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 1 And Target.Column = 1 Then
Sheet2.Cells(Sheet2.Cells(65536, 1).End(xlUp).Row + 1, 1) = Target.Value
ElseIf Target.Row = 1 And Target.Column = 2 Then
Sheet2.Cells(Sheet2.Cells(65536, 2).End(xlUp).Row + 1, 2) = Target.Value
ElseIf Target.Row = 1 And Target.Column = 3 Then
Sheet2.Cells(Sheet2.Cells(65536, 3).End(xlUp).Row + 1, 3) = Target.Value
ElseIf Target.Row = 1 And Target.Column = 4 Then
Sheet2.Cells(Sheet2.Cells(65536, 4).End(xlUp).Row + 1, 4) = Target.Value
End If
End Sub
不过这样做有一个缺点,就是每当你在Sheet1中点进这四个格的时候,都会触发这个过程的执行,增添无用数据,所以建议,像你的图上这样,增加一个按钮,输完这四个单元格之后,点一下按钮,才把数据添加进Sheet2中去.
HI 我,详细说说。