PC Review


Reply
Thread Tools Rate Thread

Create multiple rows

 
 
=?Utf-8?B?VC4gTmVpbA==?=
Guest
Posts: n/a
 
      1st May 2007
Hi--
Is there a simple way of duplicating a row multiple times based on a value?

For example, I want to create labels in word based on the number of packages
a customer has purchased. Word needs a separate record for each label
produced.
If i have the customer info in a row with the number of labels needed in the
final cell, is there a way of writing a macro to duplicate (either in the
same worksheet or a new one) that would create multiple rows based on the
value in the last cell?

Any advice would be appreciated!
 
Reply With Quote
 
 
 
 
okrob
Guest
Posts: n/a
 
      1st May 2007
Sub insert_Rows()
Dim rng As Range, i As Integer, cnt As Integer
Set rng = Cells(Rows.Count, 1).End(xlUp)

For i = rng.Row To 2 Step -1
' Change 2 to 1 if you don't have a header row

cnt = Cells(i, "F").Value
' this is the column with your label count change F to suit

If cnt <> 1 Then
Cells(i, 1).EntireRow.Offset(1, 0).Resize(cnt - 1).Insert
Cells(i, 1).EntireRow.Copy Destination:= _
Cells(i, 1).EntireRow.Offset(1, 0).Resize(cnt - 1)
Else
End If
Next
End Sub


On May 1, 11:56 am, T. Neil <T...@discussions.microsoft.com> wrote:
> Hi--
> Is there a simple way of duplicating a row multiple times based on a value?
>
> For example, I want to create labels in word based on the number of packages
> a customer has purchased. Word needs a separate record for each label
> produced.
> If i have the customer info in a row with the number of labels needed in the
> final cell, is there a way of writing a macro to duplicate (either in the
> same worksheet or a new one) that would create multiple rows based on the
> value in the last cell?
>
> Any advice would be appreciated!



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create multiple rows that follows a series Robin Microsoft Excel Misc 0 16th Aug 2009 11:25 PM
subforms How to create a multiple rows for one record? Charlie Microsoft Access Forms 2 6th Jul 2008 05:26 AM
How to create a macro to delete multiple rows? gak27 Microsoft Excel Misc 4 28th Dec 2007 04:51 PM
Need to create 1 row per employee from a table of multiple rows =?Utf-8?B?RXJpa2EgRmVybWFpbnRz?= Microsoft Access Queries 8 9th Dec 2004 05:04 AM
Create multiple rows of tabs Steve Bowman Microsoft Excel Misc 2 21st Mar 2004 12:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:04 AM.