I need a vba that will do the calculation of the data and paste the result to column B

so plz look sir

plz see the attached file

Other Excel Questions

Excel Tutorials

0

I need a vba that will do the calculation of the data and paste the result to column B

so plz look sir

plz see the attached file

Do you realise that some of the world's best programmers are female, sir? What's the calculation to be performed?

Variatus (rep: 3313) Jul 14, '19 at 5:37 pm

It's just a spreadsheet of numbers and no discernable formula or calculation to be performed...

don (rep: 1735) Jul 14, '19 at 11:40 pm

no sir the data starts from column C and it can end with any column so we have to calculate the data from column C to last data in that row and paste the calculated result to column B

It's not about male or female mam the game is all about Knowledge

It's not about male or female mam the game is all about Knowledge

style36 (rep: 24) Jul 15, '19 at 4:44 pm

There are 4 basic calculation methods (add, subtract, divide and multiply). Excel also can do some more, requiring higher levels of algebra. Jus tlimiting ourselves to the basics, the number of possible calculations multiplies exponentially with the number of factors. Since you say that there might be as many as 16282 numbers in a row (from column C to the maximum number of columns in a sheet) the number of possible calculations that might be done with them is in the trillions of trillions. Could you limit your requirements perhaps just a little?

Variatus (rep: 3313) Jul 15, '19 at 9:53 pm

0

Selected Answer

How does this formula work for you?

`=SUM(C2:AZ2)`

Write it to B2 and copy down. It will add up the 50 numbers to right of B2. Blanks and text will be counted as zero.

I have presumed that you might not have more than 50 numbers in a row. If that estimate is too big, reduce the sum range. Consider Z2 instead of AZ2 for a possible maximum of 24 used columns C:Z. The next column after AZ is BA. Therefore, extending the sum range to BZ would add another 26 numbers to the sum range.

The code below would do the same thing using VBA.

```
Sub WriteRowTotals()
' 16 Jul 2019
Dim Rl As Long, Cl As Long
Dim SumRng As Range
Dim R As Long
' re-define workbook if the workbook isn't the one containing the code
' replace "Sheet1" with tab name
With ThisWorkbook.Worksheets("Sheet1")
Rl = .Cells(.Rows.Count, "A").End(xlUp).Row
Cl = .UsedRange.Columns.Count
' row 2 is the first row to sum up
For R = 2 To Rl
Set SumRng = .Range(.Cells(R, "C"), .Cells(R, Cl))
' write the result to column B
.Cells(R, "B").Value = Application.Sum(SumRng)
Next R
End With
End Sub
```