New Excel Forum

This forum has been moved to TeachExcel.com

Ask all future questions in the New Excel Forum.

ExcelKey

VBA Macro to sum a variable range and put the result in the specified column

Macros, VBA, Excel Automation, etc.

VBA Macro to sum a variable range and put the result in the specified column

Postby Wither125 » Mon May 16, 2016 5:09 pm

Hello,

I am creating a macro that would calculate the sum from the column(TOTAL_DLR_AM) of the table(calculation) and paste the calculated sum in the next table(Approvals Summary) in the column(Sum).
However i try but i am only able to calculate the sum but not able to paste the calculated sum in the column(Sum).

I am not using the range select because the data in the table (calculation) will very.

Below is the code:

Sub Macro()

Windows("techdata.xlsm").Activate
Sheet1.Activate
ActiveCell.FormulaR1C1 = "Sum"
ActiveCell.Offset(0, 1).Select
myrow = Range("E6666").End(xlUp).Row
ActiveCell.Offset(0, 4).Formula = "=SUM(E3:E" & myrow & ")"

Sheet1.Columns().AutoFit

End Sub

I am not getting any errors when running the macro but it doesn't paste the calculated sum in the column (Sum).

Looking forward for your answer and Thanks for your help in advance!
  • 0

You do not have the required permissions to view the files attached to this post.
Last edited by Wither125 on Tue May 17, 2016 3:14 pm, edited 1 time in total.
Wither125
Rookie
 
Posts: 3
Joined: May 16, 2016
Reputation: 0
Excel Version: 2010

Re: VBA Macro to sum a variable range and put the result in the specified column

Postby pecoflyer » Tue May 17, 2016 1:53 am

Hi

please add code tags as retested. Thx
  • 0

A relevant topic title helps get faster and more answers
pecoflyer
Moderator
 
Posts: 1274
Joined: Jan 24, 2012
Location: Belgium
Reputation: 39
Excel Version: 2003/2007/2010

Re: VBA Macro to sum a variable range and put the result in the specified column

Postby pecoflyer » Wed May 18, 2016 1:13 am

Duplicate - Thread closed
  • 0

A relevant topic title helps get faster and more answers
pecoflyer
Moderator
 
Posts: 1274
Joined: Jan 24, 2012
Location: Belgium
Reputation: 39
Excel Version: 2003/2007/2010


Return to Macros and VBA Questions

Who is online

Users browsing this forum: No registered users and 45 guests

cron