ExcelArtist
New Member
- Joined
- Jun 1, 2014
- Messages
- 3
Hello all,
I've created a macro where I add values from one column with 2 values in another column that looks like this:
Range("a1").Select
ActiveCell.Value = "=sum(d1,f1:f2)"
Range("a2").Select
ActiveCell.Value = "=sum(d2,f3:f4)"
Range("a3").Select
ActiveCell.Value = "=sum(d3,f5:f6)"
This code also does what I want, but without using a loop(s):
Cells(1,1).Value = Cells(1,1).Offset(0,3).Value + Cells(1,1).Offset(0,5).Value + Cells(1,1).Offset(1,5).Value
Cells(2,1).Value = Cells(1,1).Offset(1,3).Value + Cells(1,1).Offset(2,5).Value + Cells(1,1).Offset(3,5).Value
Cells(3,1).Value = Cells(1,1).Offset(2,3).Value + Cells(1,1).Offset(4,5).Value + Cells(1,1).Offset(5,5).Value
I've tried using nested for next loops and a nested do until loop, but it seems like this isn't the right solution.
The closest I've gotten is to increment the variable by step 2, but the results are then placed in every other row
Any help / suggestions on how to use multiple variables in a nested loop would be greatly appreciated! Thanks!!
I've created a macro where I add values from one column with 2 values in another column that looks like this:
Range("a1").Select
ActiveCell.Value = "=sum(d1,f1:f2)"
Range("a2").Select
ActiveCell.Value = "=sum(d2,f3:f4)"
Range("a3").Select
ActiveCell.Value = "=sum(d3,f5:f6)"
This code also does what I want, but without using a loop(s):
Cells(1,1).Value = Cells(1,1).Offset(0,3).Value + Cells(1,1).Offset(0,5).Value + Cells(1,1).Offset(1,5).Value
Cells(2,1).Value = Cells(1,1).Offset(1,3).Value + Cells(1,1).Offset(2,5).Value + Cells(1,1).Offset(3,5).Value
Cells(3,1).Value = Cells(1,1).Offset(2,3).Value + Cells(1,1).Offset(4,5).Value + Cells(1,1).Offset(5,5).Value
I've tried using nested for next loops and a nested do until loop, but it seems like this isn't the right solution.
The closest I've gotten is to increment the variable by step 2, but the results are then placed in every other row
Any help / suggestions on how to use multiple variables in a nested loop would be greatly appreciated! Thanks!!