passing sum formula into macro

sherrypah30

New Member
Joined
Apr 16, 2013
Messages
3
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 :
Case Is = Worksheets("ReadyFile_Template").Cells(70, 2).Formula
For b = 5 To (intIncumbentCount + 4)
Worksheets("ReadyFile_Output").Cells(b, a).Formula = "=sum(bk5:bm5)"
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

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
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])"
 
Upvote 0
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.
 
Upvote 0
Sub assign_Values()
dim CL as integer
strCL = Worksheets("ReadyFile_Template").Cells(70, 1).Formula
For a = 1 To intCountCol
strChkvalue = Worksheets("ReadyFile_Output").Cells(4, a).Value
Select Case strChkvalue
Case Is = Worksheets("ReadyFile_Template").Cells(70, 2).Formula
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,392
Messages
6,119,255
Members
448,879
Latest member
oksanana

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top