LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.newusers
Lvenom
 
Posts: n/a
Default AutoSum macros


With alot of reading, I have been able to piece together some code to
auto sum a variable length column. My column data is coming from a
filtered column on a separate worksheet. My problem is, the code stops
when the filtered column from the other sheet has no data present.
(Data is filtered off of date entries and sometimes there is no data
for a specific date). How do I stop the code if there is no data to
sum? Here is the macro:

Sub totalcolumn()
'To position the cursor in the "AutoSum" cell
Range("Q2").End(xlDown).Offset(1, 0).Select
'Determine the Row numbers
vRowTop = 2
vRowBottom = ActiveCell.Offset(-1, 0).Row
'Compute the R[ ] variable
vDiff = vRowBottom - vRowTop + 1
'Enter the formulas
Selection.FormulaR1C1 = "=SUM(R[" & -vDiff & "]C:R[-1]C)"
'Move the cursor one cell to the right
Selection.Offset(0, 1).Select
'To enter the =Sum formula in the second column of data
Selection.FormulaR1C1 = "=SUM(R[" & -vDiff & "]C:R[-1]C)"
Columns("Q:R").Select


End Sub


--
Lvenom
------------------------------------------------------------------------
Lvenom's Profile: http://www.excelforum.com/member.php...o&userid=35358
View this thread: http://www.excelforum.com/showthread...hreadid=551298

 
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
Hide Macro's in Toolbar / Macro's list sparx Excel Discussion (Misc queries) 2 May 6th 06 08:53 PM
how do I run excel 4.0 macros on excel 2000 RodolfoDallas Excel Discussion (Misc queries) 1 March 12th 06 03:14 AM
Excel crashes while opening excel file imbeddied with macros ct2147 Excel Discussion (Misc queries) 0 December 30th 05 09:05 PM
Transferring toolbars and macros to other computers Darrell Excel Discussion (Misc queries) 1 January 19th 05 12:21 AM
autosum problems PAT D 1951 Excel Worksheet Functions 1 November 28th 04 11:17 PM


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

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

About Us

"It's about Microsoft Excel"