
Originally Posted by
martins
could you help a bit further - I actually have 2 columns collecting figures so instead of A1, I have C226 and C229 and the corresponding monthly cells are starting B241 (jan) and C241 (jan) respectively through to b252 and c252. Could you provide the macro for that scenario please.
Hi,
for simplicity, you can repeat the line
Sheets("Sheet1").Cells(myMonth, 3).Value = Sheets("Sheet1").Cells(1, 1).Value
with different addresses, alternately you can use the form
Sheets("Sheet1").Cells(myMonth, 3).Value = Sheets("Sheet1").Cells(1, 1).Value
Sheets("Sheet1").Range("C" & myMonth).Value = Sheets("Sheet1").Range("A1").Value
both mean the same thing, the Row increment is calculated into myMonth, so to save into C241 for Jan would be
Sheets("Sheet1").Cells(240 + myMonth, 3).Value = Sheets("Sheet1").Cells(246,3).Value
Sheets("Sheet1").Range("C" & 240 + myMonth).Value = Sheets("Sheet1").Range("C246").Value
etc.
also, to save typing and because these are all sheet1
With Sheets("Sheet1")
.Cells(240 + myMonth, 3).Value = .Cells(246,3).Value
.Range("C" & 240 + myMonth).Value = .Range("C246").Value
End With
so you can just duplicate these lines and amend the addresses as required. (only one of the lines is required, they are different forms of the same instruction)
hth
---
Bookmarks