LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 171
Default Extending a macro

Here is a simple macro I am using:

Sub Rows4()
'
' Rows4 Macro
' Macro recorded 4/20/2007 by Administrator
'

'
ActiveCell.Select
ActiveCell.FormulaR1C1 = "=RC[-6]"
ActiveCell.Offset(0, 2).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-3]C[-6]:RC[-6])"
ActiveCell.Offset(0, 2).Range("A1").Select
ActiveCell.FormulaR1C1 = "=SUM(R[-3]C[-7]:RC[-7])"
ActiveCell.Offset(1, -4).Range("A1").Select
End Sub

It is one of a family of 11 macros, each named "Rows[n]", and all I have to
do is count how many rows I need to apply a macro to, and call the macro
named for that number of rows with its hotkey. However, being fundamentally
lazy (always give the hardest task to the laziest employee, and he/she will
always find the easiest way to do it <g) -- I want to extend it a tiny bit.

I would like to change that last line to:

ActiveCell.Offset(1, -10).Range("A1").Select

This column contains years, sequentially sorted. So there could be four 1996
then five 1997, then eleven 1998 then two 1996 again. What I need to do,
after making that select is this:

--Capture the value in the selected cell
--Scroll down, counting the rows until I find a different value
--Scroll back up one row, and hold the adjusted count for number of rows
--Scroll back to the right 6 columns to my "starting cell"
--Invoke the Macro based on the number of rows counted ("Rows3" e.g.)

The table has nearly 9,000 rows, and doing this junk manually I have reached
row 800 in some two hours. If I could modify the macros to do this, it would
do the whole shebang in a couple of heartbeats!

All contributions gratefully received.
Dave
Temping with Staffmark
in Rock Hill, SC
 
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
extending columns Bob New Users to Excel 3 December 24th 06 11:12 PM
Extending VLOOKUP Krish Excel Worksheet Functions 2 September 5th 06 07:26 AM
Extending Row() Colin Hayes Excel Worksheet Functions 4 December 20th 05 11:41 PM
extending selection Flip Excel Discussion (Misc queries) 5 April 5th 05 11:17 AM
extending dates Sanford Lefkowitz Excel Discussion (Misc queries) 2 February 22nd 05 09:30 PM


All times are GMT +1. The time now is 02:51 PM.

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"