在单元格 A2 中我有值 F,在 B2 中我有内容“4”,然后是指向 F4 单元格值的宏。我已经编写了以下代码,但它给出了对象错误。请帮忙
Sub TransferValues()
Dim rngA As Range
Dim rngB As Range
Dim srcAddress As Range
Dim destAddress As Range
Dim r As Long 'row iterator
VarW1 = "a.xlsx"
Sht1 = "Sheet1"
Set rngA = Range("H2", Range("H2").End(xlDown))
Set rngB = rngA.Offset(0, 1)
For r = 1 To rngA.Rows.Count
Set srcAddress = Range(rngA(r).Value & Range("H2").Value).Value
Set destAddress = Range(rngB(r).Value & Range("I2").Value).Value
destAddress.Value = srcAddress.Value
Next
End Sub)