Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-15-2011, 01:27 AM
halogen_bulb halogen_bulb is offline Summation where range vary using Macro Windows 7 32bit Summation where range vary using Macro Office 2010 32bit
Novice
Summation where range vary using Macro
 
Join Date: Nov 2011
Posts: 2
halogen_bulb is on a distinguished road
Default Summation where range vary using Macro


Hi,

How do I improve this code by getting the summation of the same column with varying rows?

Here is the code I use.

Code:
Sub sum()
'
' sum Macro
'    
    ActiveCell.FormulaR1C1 = "=SUM(R[-48]C:R[-1]C)"
    
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
End Sub
Im pretty sure there is a way to do it but I dont know how. Please help

Thanks,

Last edited by halogen_bulb; 11-15-2011 at 07:53 AM.
Reply With Quote
  #2  
Old 11-15-2011, 03:53 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is online now Summation where range vary using Macro Windows XP Summation where range vary using Macro Office 2003
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,770
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

Cross post

http://www.excelforum.com/excel-prog...ml#post2642650

Last edited by Pecoflyer; 11-15-2011 at 06:03 AM.
Reply With Quote
  #3  
Old 11-15-2011, 05:38 AM
halogen_bulb halogen_bulb is offline Summation where range vary using Macro Windows 7 32bit Summation where range vary using Macro Office 2010 32bit
Novice
Summation where range vary using Macro
 
Join Date: Nov 2011
Posts: 2
halogen_bulb is on a distinguished road
Default

Solution I gathered form this forum and other forums

Code:
Sub sumx()
Dim LastRow As Long
LastRow = Range("P65536").End(xlUp).Row + 1
     ActiveCell.Select
    Selection.Formula = "=SUM(P" & LastRow + 1 & ":" & Format(ActiveCell.Row - 1, "P#") & ")"

End Sub
[SOLVED]

Last edited by halogen_bulb; 11-15-2011 at 07:37 AM. Reason: [SOLVED]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Summation where range vary using Macro Print Macro w/ Page Range? stickyit Outlook 1 10-06-2011 09:51 AM
Summation where range vary using Macro Work Week: hours vary each day rkc Outlook 1 08-31-2011 01:17 PM
Summation where range vary using Macro Generic range for custom sort macro? tswiers Excel Programming 2 08-11-2011 02:40 AM
Summation where range vary using Macro use VBA to name a range g48dd Excel Programming 7 06-20-2011 06:34 AM
Sort Range boutells Excel 1 07-15-2009 03:02 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft