# passing sum formula into macro

#### sherrypah30

##### New Member
I want to assign a SUM formula to the next empty cell in "BK" until "BM"

I don't know how many rows there will be.

example..

row 1 : =sum(bk5:bm5)
row 2 : =sum (bk6:bm6)
row 3 : =sum (bk7:bm7)

my coding :
For b = 5 To (intIncumbentCount + 4)
Next b

i dont have idea how to passing for the next row..
using my coding only passing sum for row1 only until end of row.

### Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi and welcome to the board

Try something like this

Code:
``````Dim lstRw As Long
lstRw = Cells(Rows.Count, 2).End(xlUp).Row

Cells(70, 2).Resize(lstRw - 70, 1).FormulaR1C1 = "=SUM(R[-65]C[61]:R[-65]C[63])"``````

tq for the reply bt doesnt work

I'm not sure what isn't working, you will need to make some adjustments to the code to suit your needs. Perhaps you could be more specific as to where the formula is to go, what you would use to determine your last row.

Sub assign_Values()
dim CL as integer
For a = 1 To intCountCol
Select Case strChkvalue
For b = 5 To (intIncumbentCount + 4)
Worksheets("ReadyFile_Output").Cells(b, a).Formula = "=sum(" & bk & ":" & bm & ")"
Next b
example data in excel:
column A,Col B,Col C, CL
1. 5 6 7 =sum (A1:C1)
2. 8 4 2 =sum (A2:C2)
i want to assign value every sum of row inside column CL.

I'm sorry this makes less sense than the OP!!

Where do variables strCL, intCountCol, strChkValue, intIncumbentCount, b and a come from?
I posted some code for you to try integrate, where is this code?
I asked for some information, where is this information?

You're going to need to help and be more forthcoming and descriptive as I'm not sat looking at your spreadsheet.

Replies
2
Views
236
Replies
16
Views
283
Replies
7
Views
139
Replies
5
Views
246
Replies
4
Views
158

1,196,054
Messages
6,013,124
Members
441,749
Latest member
batel19

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back