ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro to auto sum (https://www.excelbanter.com/excel-programming/374529-macro-auto-sum.html)

childofthe1980s

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

Charles Chickering

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


childofthe1980s

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


dread

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



All times are GMT +1. The time now is 05:37 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com