Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.links
external usenet poster
 
Posts: 1
Default INserting Specific Number of Rows via macro

Hi,

I am new to writing macros...I have a few books but I can't seem to
figure this on out. So, I have the following data:

Date Fuel Price
7/1/06 $5.65
7/2/06 $7.00
7/3/06 $6.32

Basically, I need to insert 23 rows under each date (so that i have a
total of 24 rows for each date). Then, I'd like to copy the contents of
the cells above the insertion so that i have a fuel price for every
hour of each date. Does that make sense? I thought this would be
easy...and now I've wasted so much time, I could have done it manually
a million times now!

Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.links
external usenet poster
 
Posts: 1
Default INserting Specific Number of Rows via macro

Hello,

As you're getting started, try recording what you're doing in a macro
and then you can see how excel does it. It might not be efficient code,
but it will point you in the right direction.

For this example I recorded inserting 2 or 3 rows at a time to get
this,

Range("A2:A3").Select
Selection.EntireRow.Insert

This inserts new rows in rows 2 and 3 and pushes the old ones to 4 and
5. To use this for your problem, try either using a small FOR loop to
insert 23 rows or select a range that includes 23 rows and insert once.
Here's the FOR loop,

Dim Rng As Range
Dim i As Integer

Set Rng = Range("A2")

For i = 1 To 23
Rng.EntireRow.Insert
Next

Hope that helps,

Dsambo
wrote:
Hi,

I am new to writing macros...I have a few books but I can't seem to
figure this on out. So, I have the following data:

Date Fuel Price
7/1/06 $5.65
7/2/06 $7.00
7/3/06 $6.32

Basically, I need to insert 23 rows under each date (so that i have a
total of 24 rows for each date). Then, I'd like to copy the contents of
the cells above the insertion so that i have a fuel price for every
hour of each date. Does that make sense? I thought this would be
easy...and now I've wasted so much time, I could have done it manually
a million times now!

Thanks!


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
macro to repeat a formula a set number of rows apart steveo Excel Discussion (Misc queries) 1 July 10th 06 09:21 PM
formula to use when number of rows changes dynamically confused Excel Worksheet Functions 3 August 17th 05 03:55 PM
Formula for current month minus one = Quarter number in a macro. Pank Excel Discussion (Misc queries) 11 June 22nd 05 02:47 PM
inserting rows through external data source [email protected] Excel Discussion (Misc queries) 0 April 5th 05 03:16 AM
flexible paste rows function that inserts the right number of rows marika1981 Excel Discussion (Misc queries) 1 February 18th 05 02:40 AM


All times are GMT +1. The time now is 12:28 PM.

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

About Us

"It's about Microsoft Excel"