Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Is there anyway to include in a macro a sum up to the first non numerical
cell? Or in ohter words the size or name of the range varies each time you use the macro. |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Hi Carol,
Try the following. Note that blank cells evaluate as zero and are therefore numeric and hense the testing for numeric as well as for blanks. Sub SumNumeric() Dim iFirst As Long Dim iLast As Long Dim sumTotal iFirst = 2 iLast = iFirst 'Tests cells for numeric and not blank 'in column A starting at row 2 Do While IsNumeric(Cells(iLast, "A")) _ And Cells(iLast, "A") < "" iLast = iLast + 1 Loop 'iLast will be one greater than required number 'because it increments after the test 'so reduce value by 1 iLast = iLast - 1 sumTotal = WorksheetFunction _ .Sum(Range(Cells(iFirst, "A"), _ Cells(iLast, "A"))) End Sub -- Regards, OssieMac "Carol" wrote: Is there anyway to include in a macro a sum up to the first non numerical cell? Or in ohter words the size or name of the range varies each time you use the macro. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro stops working when sheet is protected | Excel Discussion (Misc queries) | |||
Opening a file stops a Macro | Excel Worksheet Functions | |||
Macro stops at random places. | Excel Discussion (Misc queries) | |||
Macro repeats and then stops | Excel Discussion (Misc queries) | |||
Vb macro stops when I try to create more than 89 charts | Charts and Charting in Excel |