![如何自动将数据从一个工作表的一个单元格转移到同一工作簿中另一个工作表的另一个单元格](https://linux22.com/image/1602710/%E5%A6%82%E4%BD%95%E8%87%AA%E5%8A%A8%E5%B0%86%E6%95%B0%E6%8D%AE%E4%BB%8E%E4%B8%80%E4%B8%AA%E5%B7%A5%E4%BD%9C%E8%A1%A8%E7%9A%84%E4%B8%80%E4%B8%AA%E5%8D%95%E5%85%83%E6%A0%BC%E8%BD%AC%E7%A7%BB%E5%88%B0%E5%90%8C%E4%B8%80%E5%B7%A5%E4%BD%9C%E7%B0%BF%E4%B8%AD%E5%8F%A6%E4%B8%80%E4%B8%AA%E5%B7%A5%E4%BD%9C%E8%A1%A8%E7%9A%84%E5%8F%A6%E4%B8%80%E4%B8%AA%E5%8D%95%E5%85%83%E6%A0%BC.png)
答案1
将以下代码插入数据源表(屏幕截图上的 Sheet2)模块:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' When selection on the worksheet is changed we check
' that only one cell is selected (not multicell range)
' and this cell is in column 1 (column A)
If Target.Column = 1 And Target.Cells.Count = 1 Then
' If one cell in column A selected, we copy the value
' from a cell right to selected (row is the same, column is greater by 1)
' to the left-up cell of solid destination range on the destination sheet
Sheets("Sheet1").Range("B2").Value = Target.Offset(0, 1).Value
' and the same for a cell where row is the same and column is greater by 2
Sheets("Sheet1").Range("E6").Value = Target.Offset(0, 2).Value
End If
End Sub