HEllo. I am trying to use VBA to sum a column of numbers that I am populating into a spreadsheet.
I am compiling data into different spreadsheets. The length of the data will vary from spreadsheet but I am trying to use a single cold to populate the a Totals Row.
I use this code in order to sum across cells in a row and it works well but in that case it is always the 12 previous cells.
Here is what I am trying to use.
Irow 2 will vary by spreadsheet so where I put the total needs to vary. I get it to print test code to the proper cells without an issue. There seems to be an issue with the Sum formula that I am using. Is it becasue I am trying to sum vertically and not horizontally?
I am compiling data into different spreadsheets. The length of the data will vary from spreadsheet but I am trying to use a single cold to populate the a Totals Row.
I use this code in order to sum across cells in a row and it works well but in that case it is always the 12 previous cells.
VBA Code:
wsps.Cells(Z, 16) = "=sum(RC[-12]:RC[-1])"
Here is what I am trying to use.
Code:
irow2 = wsm.Cells(Rows.Count, 1).End(xlUp).Row
For Z = 4 To 55
wsm.Cells(irow2 + 1, Z) = "=sum(R[-irow2]C:R[-1]C)"
Next Z
Irow 2 will vary by spreadsheet so where I put the total needs to vary. I get it to print test code to the proper cells without an issue. There seems to be an issue with the Sum formula that I am using. Is it becasue I am trying to sum vertically and not horizontally?