PC Review


Reply
Thread Tools Rate Thread

add a row after every unique number

 
 
Kirk
Guest
Posts: n/a
 
      2nd Mar 2009
Is there a macro I could use to insert 16 rows after each change in value in
Column A?

Thanks,
Kirk
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      2nd Mar 2009
Hi,

Right click your sheet tab, view code and paste this and run it.

Sub insertrowifnamechg()
MyColumn = "A"
For x = Cells(Rows.Count, MyColumn).End(xlUp).Row To 2 Step -1
If Cells(x - 1, MyColumn) <> Cells(x, MyColumn) Then
For i = 1 To 16
Rows(x).Insert
Next
End If
Next x
End Sub

Mike

"Kirk" wrote:

> Is there a macro I could use to insert 16 rows after each change in value in
> Column A?
>
> Thanks,
> Kirk

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      2nd Mar 2009
On reflection, I prefer this method

Sub insertrowifnamechg()
MyColumn = "A"
For x = Cells(Rows.Count, MyColumn).End(xlUp).Row To 2 Step -1
If Cells(x - 1, MyColumn) <> Cells(x, MyColumn) Then
Rows(x).Resize(16).Insert
End If
Next x
End Sub

Mike

"Mike H" wrote:

> Hi,
>
> Right click your sheet tab, view code and paste this and run it.
>
> Sub insertrowifnamechg()
> MyColumn = "A"
> For x = Cells(Rows.Count, MyColumn).End(xlUp).Row To 2 Step -1
> If Cells(x - 1, MyColumn) <> Cells(x, MyColumn) Then
> For i = 1 To 16
> Rows(x).Insert
> Next
> End If
> Next x
> End Sub
>
> Mike
>
> "Kirk" wrote:
>
> > Is there a macro I could use to insert 16 rows after each change in value in
> > Column A?
> >
> > Thanks,
> > Kirk

 
Reply With Quote
 
Kirk
Guest
Posts: n/a
 
      2nd Mar 2009
Hey Mike,

That worked perfectly.

Thanks for your help.
Kirk

"Mike H" wrote:

> Hi,
>
> Right click your sheet tab, view code and paste this and run it.
>
> Sub insertrowifnamechg()
> MyColumn = "A"
> For x = Cells(Rows.Count, MyColumn).End(xlUp).Row To 2 Step -1
> If Cells(x - 1, MyColumn) <> Cells(x, MyColumn) Then
> For i = 1 To 16
> Rows(x).Insert
> Next
> End If
> Next x
> End Sub
>
> Mike
>
> "Kirk" wrote:
>
> > Is there a macro I could use to insert 16 rows after each change in value in
> > Column A?
> >
> > Thanks,
> > Kirk

 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      2nd Mar 2009
Your welcome

"Kirk" wrote:

> Hey Mike,
>
> That worked perfectly.
>
> Thanks for your help.
> Kirk
>
> "Mike H" wrote:
>
> > Hi,
> >
> > Right click your sheet tab, view code and paste this and run it.
> >
> > Sub insertrowifnamechg()
> > MyColumn = "A"
> > For x = Cells(Rows.Count, MyColumn).End(xlUp).Row To 2 Step -1
> > If Cells(x - 1, MyColumn) <> Cells(x, MyColumn) Then
> > For i = 1 To 16
> > Rows(x).Insert
> > Next
> > End If
> > Next x
> > End Sub
> >
> > Mike
> >
> > "Kirk" wrote:
> >
> > > Is there a macro I could use to insert 16 rows after each change in value in
> > > Column A?
> > >
> > > Thanks,
> > > Kirk

 
Reply With Quote
 
Insert row and duplicate titles
Guest
Posts: n/a
 
      12th Mar 2009
Mike,
can you please tell me after inserting row how I can copy and paste the
headings or titles that I have on A1:P1 on every row that has been inserted.
Thank you in advance
RA
"Mike H" wrote:

> Your welcome
>
> "Kirk" wrote:
>
> > Hey Mike,
> >
> > That worked perfectly.
> >
> > Thanks for your help.
> > Kirk
> >
> > "Mike H" wrote:
> >
> > > Hi,
> > >
> > > Right click your sheet tab, view code and paste this and run it.
> > >
> > > Sub insertrowifnamechg()
> > > MyColumn = "A"
> > > For x = Cells(Rows.Count, MyColumn).End(xlUp).Row To 2 Step -1
> > > If Cells(x - 1, MyColumn) <> Cells(x, MyColumn) Then
> > > For i = 1 To 16
> > > Rows(x).Insert
> > > Next
> > > End If
> > > Next x
> > > End Sub
> > >
> > > Mike
> > >
> > > "Kirk" wrote:
> > >
> > > > Is there a macro I could use to insert 16 rows after each change in value in
> > > > Column A?
> > > >
> > > > Thanks,
> > > > Kirk

 
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
How do i give unique number in set of duplicate number? Vilish Microsoft Excel Misc 2 12th May 2009 03:33 PM
Order Number Unique Number Auto Incrementing Louise54 Microsoft Access Database Table Design 8 28th Apr 2008 05:33 PM
Finding unique names--then converting those names to unique number =?Utf-8?B?UHJvdG9u?= Microsoft Excel Misc 7 13th Jun 2007 10:22 PM
create a unique reference number of letters and sequential number =?Utf-8?B?amFuZWFzaGFycA==?= Microsoft Access Getting Started 1 13th Apr 2006 06:43 PM
Unique Number Paul Martin Microsoft Outlook Form Programming 1 24th Aug 2004 01:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:35 AM.