PDA

View Full Version : Solved: add column values



prasadksu
04-01-2009, 02:55 PM
Hello everybody,

I am kind of new to VBA programming. How can I add column A values and column C values and place it in column F. I mean adding A2 + C2 and keeping it in F2 and so on for n rows using VBA programing.

Thanks,
Prasad.

prasadksu
04-01-2009, 06:57 PM
With the following code i can add columns A and B and keep in F but I want to sum A,C,D, then this code is not working............can anyone direct me the right code.......


Sub test()

Dim irow1 As Integer

For irow1 = 1 To 6


Cells(irow1 + 1, 6).Value = WorksheetFunction.Sum(Range(Cells(irow1 + 1, 1), Cells(irow1 + 1, 2)))

Next irow1

End Sub

prasadksu
04-01-2009, 07:02 PM
never mind...........I found the right code


Sub test()

Dim irow1 As Integer

For irow1 = 1 To 6


Cells(irow1 + 1, 6).Value = ((Cells(irow1 + 1, 1) + Cells(irow1 + 1, 2) + Cells(irow1 + 1, 4)))

Next irow1

End Sub


Thanks.........