![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 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 ] |
|
|
|
|
|
#2 | |
|
Board Regular
Join Date: Apr 2002
Location: Kissimmee, Florida
Posts: 384
|
Quote:
__________________
Hope This Helps. Sean. Digest of Homes WinXP, XL XP |
|
|
|
|
|
|
#3 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Something like:
Code:
Sub sum() MsgBox Application.sum([a1:a65536]) End Sub |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: Tulsa, OK
Posts: 354
|
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 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|