Macros with formula

Rick DeLa

New Member
Joined
May 7, 2002
Messages
14
Help! I am recording a macro and here is my delema: I need to add a1 and a2 to get totals. I record the macro and lets say data only goes up to row 10. The macro stops at row 10. Problem is that I export data to this workbook and it coulb be more that 10 rows! but my macro only goes to ten. Is there a way to tell it (formula)if there is data sum it.

Your help will be greatly appreciated!!

Let me start over I need to put a formula in j2 that will sum o2:p2 the 02:p2 will have different data all the time (sometimes it call go all the way to row 10 or row 100 I need a formula on j2 that can sum those three columns all the time. I am creating a macro.
This message was edited by Rick DeLa on 2002-05-08 15:49
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
On 2002-05-08 15:18, Rick DeLa wrote:
Help! I am recording a macro and here is my delema: I need to add a1 and a2 to get totals. I record the macro and lets say data only goes up to row 10. The macro stops at row 10. Problem is that I export data to this workbook and it coulb be more that 10 rows! but my macro only goes to ten. Is there a way to tell it (formula)if there is data sum it.

Your help will be greatly appreciated!!

Rick, there's not enough info, can you include the macro code and also some of your data, its not very clear what you are trying to sum.
 
Upvote 0
Something like:

Code:
Sub sum()
MsgBox Application.sum([a1:a65536])
End Sub

??
 
Upvote 0
This'll work. BUT it sums from A1 to LAST CELL in Column A that has data (Any kind of data)

Sub SumColumnA()

'Selects Range from A1 to LAST cell in column A with data
Range("A1", Range("A65536").End(xlUp).Address).Select

'Insert SUM Formula to sum selection that was selected above
Range("A65536").End(xlUp).Offset(1, 0).Formula = "=SUM(" & Selection.Address & ")"

End Sub


Hope this helps!

EDIT: If there is no data, it'll just show a zero in A1.
This message was edited by Cosmos75 on 2002-05-08 15:37
 
Upvote 0

Forum statistics

Threads
1,214,563
Messages
6,120,248
Members
448,952
Latest member
kjurney

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