eliudblabla
New Member
- Joined
- Sep 12, 2021
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
Hi everyone,
I´m faily new to VBA, and I´m having some issues trying to enter a function to sum the values of a row within a range of columns.
My document has a column for totals, and some other columns populated with data from another sheet. I want the totals column to sum the values in the remaining columns for that specific row.
Right now I´m stuck with the totals column showing the total sum for all values in all different rows, instead of only one row. Something similar to this:
One thing to mention: the number of rows is variable, since they are populated based on certain criteria applied to data from another sheet, so I cannot reference specific cell values.
The code that I´ve used is this, where A is defined as the totals column in Sheet 1:
Worksheets("Sheet1").Activate
A = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Sheet1").Cells(1 + 1, 1).Value = WorksheetFunction.Sum(Range("B:E"))
Can somebody please help with this?
I´m faily new to VBA, and I´m having some issues trying to enter a function to sum the values of a row within a range of columns.
My document has a column for totals, and some other columns populated with data from another sheet. I want the totals column to sum the values in the remaining columns for that specific row.
Right now I´m stuck with the totals column showing the total sum for all values in all different rows, instead of only one row. Something similar to this:
Totals | B | C | D | E |
1 | 0 | 0 | 0 | 1 |
5 | 1 | 1 | 1 | 1 |
9 | 0 | 1 | 2 | 1 |
12 | 0 | 1 | 1 | 1 |
One thing to mention: the number of rows is variable, since they are populated based on certain criteria applied to data from another sheet, so I cannot reference specific cell values.
The code that I´ve used is this, where A is defined as the totals column in Sheet 1:
Worksheets("Sheet1").Activate
A = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
Worksheets("Sheet1").Cells(1 + 1, 1).Value = WorksheetFunction.Sum(Range("B:E"))
Can somebody please help with this?