我之前发过类似的东西,以为我有它,并删除了我的帖子。啊。所以,这就是我想要实现的目标:
我无法正确获取偏移值。它改为给我range1 R3值。
建议?
示例:
Set range1 = wbk1.Worksheets(1).Range(R3:R20)
Set range2 = wbk2.worksheets(2).Range("N" & .Rows.Count).End(xlup).Offset(1,0)
Set range3 = wbk2.worksheets(2).Range("O" & .Rows.Count).End(xlup).Offset(1,0)
Set range4 = range1.Offset(0,-16)
For Each c in g.keys
For Each d in range1
If c = d Then
range2.Value = d
range3.value = range4.value (this isn't working)
End If
Next d
Next c
最终守则:
Set rngchassIP = wbkJackPot.Worksheets(1).Range("R3:R30")
Set rngchassCS = wbkVer.Worksheets("Cutsheets").Range("M2:M5")
Set rngchassyver = wbkVer.Worksheets("Cutsheets").Range("N" & .Rows.Count).End(xlUp).Offset(1, 0)
Set rngchassypst = wbkVer.Worksheets("Cutsheets").Range("O" & .Rows.Count).End(xlUp).Offset(1, 0)
For Each c In rngchassCS
For Each w In rngchassIP
If c = w Then
rngchassyver.Value = w
rngchassypst.Value = w.Offset(0, -16)
End If
Next w
Next c
问题的根源是,一旦确定了w的值/位置,我需要从该单元格中获取偏移量(0,-16)并将其放入“O”中。我尝试了几种不同的方法,但我只是没有看到它......呃。求救!
答案 0 :(得分:1)
只是猜测你在这里要做什么......
Set range1 = wbk1.Worksheets(1).Range("R3:R20")
'are range 2 and 3 on the same row?
Set range2 = wbk2.worksheets(2).Range("N" & .Rows.Count).End(xlup).Offset(1,0)
Set range3 = wbk2.worksheets(2).Range("O" & .Rows.Count).End(xlup).Offset(1,0)
For Each c in g.keys
For Each d in range1.Cells
If c = d Then
range2.Value = d
range3.value = d.Offset(0,-16)
'What now? Once one match has been found,
' any later matches will write to the same cells...
End If
Next d
Next c