Sub insertspacesandline()
For i = Cells(Rows.Count, "d").End(xlUp).Row To 2 Step -1
If Cells(i - 1, "d") <> Cells(i, "d") Then
Rows(i).Insert
Cells(i - 1, "d").Borders(xlEdgeBottom).LineStyle = xlContinuous
End If
Next i
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Pman" <(E-Mail Removed)> wrote in message
news:FB957D7F-7AD8-4679-9E8D-(E-Mail Removed)...
> Hi Don,
>
> Is it possible to insert a line/ border whenever I insert the row?
>
> Thanks again 
>
> -Pman
>
> "Don Guillett" wrote:
>
>> copy this macro into a module.
>>
>> Sub insertspaces()
>> For i = Cells(Rows.Count, "b").End(xlUp).Row To 2 Step -1
>> If Cells(i - 1, "b") <> Cells(i, "b") Then Rows(i).Insert
>> Next i
>> End Sub
>>
>> --
>> Don Guillett
>> Microsoft MVP Excel
>> SalesAid Software
>> (E-Mail Removed)
>> "Pman" <(E-Mail Removed)> wrote in message
>> news:8E19B5A0-7AF5-4978-A57D-(E-Mail Removed)...
>> > Hi,
>> >
>> > I have an excel file which goes like this in my first 2 columns:
>> >
>> > PRODUCT PUBLICATION
>> > NAME
>> >
>> > Product 1 publication 1
>> > publication 1
>> > publication 2
>> > Product 2 publication 1
>> > publication 1
>> > publication 2
>> > Product 3 publication 3
>> > Product 4 publication 2
>> >
>> > This file runs in 20k + rows.....and I need to insert a new row
>> > whenever I
>> > encounter a new product or publication. The end result as I want is
>> > below:
>> >
>> > PRODUCT PUBLICATION
>> > NAME
>> >
>> > Product 1 publication 1
>> > publication 1
>> >
>> > publication 2
>> >
>> > Product 2 publication 1
>> > publication 1
>> >
>> > publication 2
>> >
>> > Product 3 publication 3
>> >
>> > Product 4 publication 2
>> >
>> > Notice that there's a row between new products and new publications.
>> > Can
>> > someone tell me an easier way to do it , or than doing it manually for
>> > 20,000+ rows?
>> >
>> > Thanks 
>> >
>> > P
>>
>>