Hello everyone,
I have two excel Workbooks (WB1 & WB2), WB1 one has an input tab (G2) where I paste the values from WB2 (Range: B2:B78) to get an output (G3) which I want to have pasted back into WB2 ( in Column D2:D78). I have about 78 rows to go through and thought this could be a good application to try out looping however, I can't seem to get it to loop through all the rows.
I have two excel Workbooks (WB1 & WB2), WB1 one has an input tab (G2) where I paste the values from WB2 (Range: B2:B78) to get an output (G3) which I want to have pasted back into WB2 ( in Column D2:D78). I have about 78 rows to go through and thought this could be a good application to try out looping however, I can't seem to get it to loop through all the rows.
VBA Code:
Sub loopthru()
Dim rng As Range, cell As Range
Set rng = Range("B2:B78")
For Each cell In rng
Range("B2").Select
Selection.Copy
Windows("WB1.xlsx").Activate
Range("G2").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Range("G3").Select
Windows("wb2.xlsx").Activate
Range("D2").PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Next cell
End Sub
Last edited: