
答案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