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

Hello:

Is it possible to create a macro in Excel that will sum up a column of data,
rather than having the end user press the AutoSum button? I know it sounds
"lazy" on the user's part, but there is a good reason.

The situation is that an external application is going to be exporting data
to Excel, and the application can use Excel macros perfectly. I want to
create a macro in Excel that will automatically sum up a column of data
immediately after the data is exported to Excel.

Now, the number of records in that column is not going to be the same
everytime. I mean, the number of records one time might be 30, the next time
it might be 40, etc.?

Is this all possible to do in a macro?

Thanks!

childofthe1980s
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default macro to auto sum

Sub AutoSumForLazyUsers()
Range("A" & Rows.Count).End(xlUp).Offset(1).FormulaR1C1 = _
"=Sum(R1C:R[-1]C)" 'Change "A" to Your Column and 'R1C' to your first row
End Sub

--
Charles Chickering

"A good example is twice the value of good advice."


"childofthe1980s" wrote:

Hello:

Is it possible to create a macro in Excel that will sum up a column of data,
rather than having the end user press the AutoSum button? I know it sounds
"lazy" on the user's part, but there is a good reason.

The situation is that an external application is going to be exporting data
to Excel, and the application can use Excel macros perfectly. I want to
create a macro in Excel that will automatically sum up a column of data
immediately after the data is exported to Excel.

Now, the number of records in that column is not going to be the same
everytime. I mean, the number of records one time might be 30, the next time
it might be 40, etc.?

Is this all possible to do in a macro?

Thanks!

childofthe1980s

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 122
Default macro to auto sum

Thanks, Charles!

childofthe1980s

"Charles Chickering" wrote:

Sub AutoSumForLazyUsers()
Range("A" & Rows.Count).End(xlUp).Offset(1).FormulaR1C1 = _
"=Sum(R1C:R[-1]C)" 'Change "A" to Your Column and 'R1C' to your first row
End Sub

--
Charles Chickering

"A good example is twice the value of good advice."


"childofthe1980s" wrote:

Hello:

Is it possible to create a macro in Excel that will sum up a column of data,
rather than having the end user press the AutoSum button? I know it sounds
"lazy" on the user's part, but there is a good reason.

The situation is that an external application is going to be exporting data
to Excel, and the application can use Excel macros perfectly. I want to
create a macro in Excel that will automatically sum up a column of data
immediately after the data is exported to Excel.

Now, the number of records in that column is not going to be the same
everytime. I mean, the number of records one time might be 30, the next time
it might be 40, etc.?

Is this all possible to do in a macro?

Thanks!

childofthe1980s

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default macro to auto sum

Hi Charles,

I tried this with something I'm working on and it worked great, but I also
need to delete any blank rows I have before the auto sum takes place. What
can I add to this code to delete the blank rows?

Thanks

"Charles Chickering" wrote:

Sub AutoSumForLazyUsers()
Range("A" & Rows.Count).End(xlUp).Offset(1).FormulaR1C1 = _
"=Sum(R1C:R[-1]C)" 'Change "A" to Your Column and 'R1C' to your first row
End Sub

--
Charles Chickering

"A good example is twice the value of good advice."


"childofthe1980s" wrote:

Hello:

Is it possible to create a macro in Excel that will sum up a column of data,
rather than having the end user press the AutoSum button? I know it sounds
"lazy" on the user's part, but there is a good reason.

The situation is that an external application is going to be exporting data
to Excel, and the application can use Excel macros perfectly. I want to
create a macro in Excel that will automatically sum up a column of data
immediately after the data is exported to Excel.

Now, the number of records in that column is not going to be the same
everytime. I mean, the number of records one time might be 30, the next time
it might be 40, etc.?

Is this all possible to do in a macro?

Thanks!

childofthe1980s

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
Sub Macro vrs Function Macro Auto Start Pat Excel Discussion (Misc queries) 7 June 6th 07 09:53 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Auto-run macro after auto-query refresh (Excel2000,sr1) Bill Cufflin Excel Programming 3 June 29th 06 03:30 AM
Auto macro George Davis Excel Programming 2 February 5th 06 04:30 PM
auto run a macro garima agrawal Excel Programming 2 August 9th 03 07:30 AM


All times are GMT +1. The time now is 11:37 AM.

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"