If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > VBA Macro to autofill rows

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-08-07, 05:10
dnguyen72 dnguyen72 is offline
Registered User
 
Join Date: Nov 2007
Posts: 1
Red face VBA Macro to autofill rows

Hello,

Wondering if anyone has some VBA codes that could do the following automatically:

I have a spreadsheet with approx 250 unique rows of data. I need to insert 30 rows and fill in those rows with the same information for each of the 250 rows. For example:

current data is

1 CG CA Grain 5.5 35368.4
1 CC CA Coal 8 54418.4
...........

need to do the following:

1 CG CA Grain 5.5 35368.4
1 CG CA Grain 5.5 35368.4
...30 times...

then start on the new row...

1 CC CA Coal 8 54418.4
1 CC CA Coal 8 54418.4
...30 times...

and so on...

Anything to help automate this process would be much appreciated.

Thanks in advance for your help.
David
Reply With Quote
  #2 (permalink)  
Old 11-09-07, 01:12
myle myle is offline
(Making Your Life Easy)
 
Join Date: Feb 2004
Location: New Zealand
Posts: 1,143
the base way I leant was record a macro doing the job
then look @ the code and tweak it
__________________
hope this help

See clear as mud


StePhan McKillen
the aim is store once, not store multiple times
Remember... Optimize 'til you die!
Progaming environment:
Access based on my own environment: DAO3.6/A97/A2000/A2003
VB based on my own environment: vb6 sp5
ASP based on my own environment: 5.6
VB-NET based on my own environment started 2007
SQL-2005 based on my own environment started 2008
MYLE
Reply With Quote
  #3 (permalink)  
Old 11-10-07, 12:02
norie norie is offline
Registered User
 
Join Date: Mar 2006
Posts: 163
David

You don't say where this data is located but you could try something like this.
Code:
Sub Do30()
Dim rng As Range
    
    Set rng = Range("A1")
    While rng.Value <> ""
        rng.EntireRow.Copy
        rng.Offset(1).Resize(29).Insert
        Set rng = rng.Offset(30)
    Wend
    Application.CutCopyMode = False
    
End Sub
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On