Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default MACRO question


I undertake a repetitive task, which seems to me is begging to be
turned into a macro. The extent of my knowledge of macros is (a)
start recording, (b) do some stuff, (c) stop recording. For most
purposes this has been just fine. Now I want to do some more complex
things and I've run into a problem.

I have a column of numbers (say, for this example, A2, A3, A4). I
wish to sum the column. I usually make the cell immediately to the
right of the top number active (B2), and use autosum. Autosum is
great, as it highlights the top of my column of numbers, and I can
then use ctrl-shift-downarrow to automatically capture all my data.
What this does is creates this formula: =SUM(A2:A4).

I recorded my macro, doing just that, and it worked fine. But here is
the problem. The number of rows in my data is variable from one day
to the next. The next time I wish to do the calculation, my data
might run from, say, A2, A3, A4, A5. However, the macro retains the
formula =SUM(A2:A4), whereas is should be =SUM(A2:A5).

How do I make the formula dynamic based on the number of rows?

Ron
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default MACRO question

OP wanted to start with A2, not a1

--
Don Guillett
SalesAid Software

"Kurt M. Sanger" wrote in message
...
sum(a:a) will sum all the numbers in column A.

"Don Guillett" wrote:

try
x=cells(rows.count,"a").end(xlup).row
msgbox application.sum(range("a2:a" & x))

--
Don Guillett
SalesAid Software

wrote in message
...

I undertake a repetitive task, which seems to me is begging to be
turned into a macro. The extent of my knowledge of macros is (a)
start recording, (b) do some stuff, (c) stop recording. For most
purposes this has been just fine. Now I want to do some more complex
things and I've run into a problem.

I have a column of numbers (say, for this example, A2, A3, A4). I
wish to sum the column. I usually make the cell immediately to the
right of the top number active (B2), and use autosum. Autosum is
great, as it highlights the top of my column of numbers, and I can
then use ctrl-shift-downarrow to automatically capture all my data.
What this does is creates this formula: =SUM(A2:A4).

I recorded my macro, doing just that, and it worked fine. But here is
the problem. The number of rows in my data is variable from one day
to the next. The next time I wish to do the calculation, my data
might run from, say, A2, A3, A4, A5. However, the macro retains the
formula =SUM(A2:A4), whereas is should be =SUM(A2:A5).

How do I make the formula dynamic based on the number of rows?

Ron






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 Macro/VB Question DDE Question MadDog22 Excel Worksheet Functions 1 March 10th 10 01:47 AM
Macro question orquidea Excel Worksheet Functions 10 February 6th 08 05:44 PM
Macro Question carl Excel Worksheet Functions 0 May 10th 07 03:29 PM
Macro Question Carl Excel Worksheet Functions 1 August 25th 06 07:40 PM
Macro Question carl Excel Worksheet Functions 0 June 8th 06 03:37 PM


All times are GMT +1. The time now is 01:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"