Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default VBA for selecting continuous cells from relative starting point?

In a spreadsheet "cleanup" macro, I can get to the last column of numbers and
write a subtotal formula. I want to copy this formula and paste to the five
columns to the left of this reference. How can I do this once instead of for
each column? This is how I have it now to paste into the one cell to the
left:

ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[-91]C:R[-1]C)"
ActiveCell.Copy
ActiveCell.Offset(0, -1).Select
ActiveSheet.Paste

Also, in the subtotal formula - R[-91] - is specific. Is there a way to
write this where excel finds the first value in the column no matter how many
rows need adding instead of me having to count how many I want it to add?

Thanks!
Valerie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default VBA for selecting continuous cells from relative starting point?

Valerie

something like:

ActiveCell.Offset(1, -5).Resize(1, 5).FormulaR1C1 = _
"=SUBTOTAL(9,R[-91]C:R[-1]C)"

Regards

Trevor


"Valerie" wrote in message
...
In a spreadsheet "cleanup" macro, I can get to the last column of numbers
and
write a subtotal formula. I want to copy this formula and paste to the
five
columns to the left of this reference. How can I do this once instead of
for
each column? This is how I have it now to paste into the one cell to the
left:

ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[-91]C:R[-1]C)"
ActiveCell.Copy
ActiveCell.Offset(0, -1).Select
ActiveSheet.Paste

Also, in the subtotal formula - R[-91] - is specific. Is there a way to
write this where excel finds the first value in the column no matter how
many
rows need adding instead of me having to count how many I want it to add?

Thanks!
Valerie



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
formula based on continuous relative cells bwilde Excel Discussion (Misc queries) 0 February 23rd 10 03:52 PM
Indexing Values to Same Starting Point for Relative Return Chart Notclevr Charts and Charting in Excel 1 January 18th 06 10:33 PM
bar chart starting point lnoles Charts and Charting in Excel 1 October 14th 05 02:16 PM
Starting Point of macro Turin Excel Programming 1 July 7th 05 12:51 PM
Bar charts with a differing starting point Teng Charts and Charting in Excel 2 April 23rd 05 03:19 AM


All times are GMT +1. The time now is 06:40 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"