+ Reply to Thread
Results 1 to 6 of 6

Add row after various groups of numbers.

  1. #1
    Josh O.
    Guest

    Add row after various groups of numbers.

    I have a sheet that contains rows with customer numbers:
    847300001
    847300001
    847300020
    847300015
    847300015
    847300015
    847300002...

    What I need to do is a blank row after each groups of numbers:
    847300001
    847300001

    847300020

    847300015
    847300015
    847300015

    847300002...

    The numbers will change each time I run the report. Any way I can do this?


  2. #2
    Tom Ogilvy
    Guest

    Re: Add row after various groups of numbers.

    Sub ABC()
    Dim lastrow as Long, i as Long
    set lastrow = cells(rows.count,1).End(xlup).Row
    for i = lastrow to 2 step -1
    if cells(i,1) <> cells(i-1,1) then
    rows(i).Insert
    end if
    Next
    End Sub

    --
    Regards,
    Tom Ogilvy


    "Josh O." <[email protected]> wrote in message
    news:[email protected]...
    > I have a sheet that contains rows with customer numbers:
    > 847300001
    > 847300001
    > 847300020
    > 847300015
    > 847300015
    > 847300015
    > 847300002...
    >
    > What I need to do is a blank row after each groups of numbers:
    > 847300001
    > 847300001
    >
    > 847300020
    >
    > 847300015
    > 847300015
    > 847300015
    >
    > 847300002...
    >
    > The numbers will change each time I run the report. Any way I can do

    this?
    >




  3. #3
    Josh O.
    Guest

    Re: Add row after various groups of numbers.

    Tom,
    Is there anything else I need to do to use this Sub. I am getting an object
    error at set lastrow =

    "Tom Ogilvy" wrote:

    > Sub ABC()
    > Dim lastrow as Long, i as Long
    > set lastrow = cells(rows.count,1).End(xlup).Row
    > for i = lastrow to 2 step -1
    > if cells(i,1) <> cells(i-1,1) then
    > rows(i).Insert
    > end if
    > Next
    > End Sub
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Josh O." <[email protected]> wrote in message
    > news:[email protected]...
    > > I have a sheet that contains rows with customer numbers:
    > > 847300001
    > > 847300001
    > > 847300020
    > > 847300015
    > > 847300015
    > > 847300015
    > > 847300002...
    > >
    > > What I need to do is a blank row after each groups of numbers:
    > > 847300001
    > > 847300001
    > >
    > > 847300020
    > >
    > > 847300015
    > > 847300015
    > > 847300015
    > >
    > > 847300002...
    > >
    > > The numbers will change each time I run the report. Any way I can do

    > this?
    > >

    >
    >
    >


  4. #4
    Dave Peterson
    Guest

    Re: Add row after various groups of numbers.

    Remove that "Set" completely:

    lastrow = cells(rows.count,1).End(xlup).Row



    Josh O. wrote:
    >
    > Tom,
    > Is there anything else I need to do to use this Sub. I am getting an object
    > error at set lastrow =
    >
    > "Tom Ogilvy" wrote:
    >
    > > Sub ABC()
    > > Dim lastrow as Long, i as Long
    > > set lastrow = cells(rows.count,1).End(xlup).Row
    > > for i = lastrow to 2 step -1
    > > if cells(i,1) <> cells(i-1,1) then
    > > rows(i).Insert
    > > end if
    > > Next
    > > End Sub
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > > "Josh O." <[email protected]> wrote in message
    > > news:[email protected]...
    > > > I have a sheet that contains rows with customer numbers:
    > > > 847300001
    > > > 847300001
    > > > 847300020
    > > > 847300015
    > > > 847300015
    > > > 847300015
    > > > 847300002...
    > > >
    > > > What I need to do is a blank row after each groups of numbers:
    > > > 847300001
    > > > 847300001
    > > >
    > > > 847300020
    > > >
    > > > 847300015
    > > > 847300015
    > > > 847300015
    > > >
    > > > 847300002...
    > > >
    > > > The numbers will change each time I run the report. Any way I can do

    > > this?
    > > >

    > >
    > >
    > >


    --

    Dave Peterson

  5. #5
    Josh O.
    Guest

    Re: Add row after various groups of numbers.

    I removed the set, and it allows the macro to run, but it doesn't do anything
    to the spreadsheet.

    "Dave Peterson" wrote:

    > Remove that "Set" completely:
    >
    > lastrow = cells(rows.count,1).End(xlup).Row
    >
    >
    >
    > Josh O. wrote:
    > >
    > > Tom,
    > > Is there anything else I need to do to use this Sub. I am getting an object
    > > error at set lastrow =
    > >
    > > "Tom Ogilvy" wrote:
    > >
    > > > Sub ABC()
    > > > Dim lastrow as Long, i as Long
    > > > set lastrow = cells(rows.count,1).End(xlup).Row
    > > > for i = lastrow to 2 step -1
    > > > if cells(i,1) <> cells(i-1,1) then
    > > > rows(i).Insert
    > > > end if
    > > > Next
    > > > End Sub
    > > >
    > > > --
    > > > Regards,
    > > > Tom Ogilvy
    > > >
    > > >
    > > > "Josh O." <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > I have a sheet that contains rows with customer numbers:
    > > > > 847300001
    > > > > 847300001
    > > > > 847300020
    > > > > 847300015
    > > > > 847300015
    > > > > 847300015
    > > > > 847300002...
    > > > >
    > > > > What I need to do is a blank row after each groups of numbers:
    > > > > 847300001
    > > > > 847300001
    > > > >
    > > > > 847300020
    > > > >
    > > > > 847300015
    > > > > 847300015
    > > > > 847300015
    > > > >
    > > > > 847300002...
    > > > >
    > > > > The numbers will change each time I run the report. Any way I can do
    > > > this?
    > > > >
    > > >
    > > >
    > > >

    >
    > --
    >
    > Dave Peterson
    >


  6. #6
    Tom Ogilvy
    Guest

    Re: Add row after various groups of numbers.

    See answer to later posting.

    --
    Regards,
    Tom Ogilvy

    "Josh O." <[email protected]> wrote in message
    news:[email protected]...
    > I removed the set, and it allows the macro to run, but it doesn't do

    anything
    > to the spreadsheet.
    >
    > "Dave Peterson" wrote:
    >
    > > Remove that "Set" completely:
    > >
    > > lastrow = cells(rows.count,1).End(xlup).Row
    > >
    > >
    > >
    > > Josh O. wrote:
    > > >
    > > > Tom,
    > > > Is there anything else I need to do to use this Sub. I am getting an

    object
    > > > error at set lastrow =
    > > >
    > > > "Tom Ogilvy" wrote:
    > > >
    > > > > Sub ABC()
    > > > > Dim lastrow as Long, i as Long
    > > > > set lastrow = cells(rows.count,1).End(xlup).Row
    > > > > for i = lastrow to 2 step -1
    > > > > if cells(i,1) <> cells(i-1,1) then
    > > > > rows(i).Insert
    > > > > end if
    > > > > Next
    > > > > End Sub
    > > > >
    > > > > --
    > > > > Regards,
    > > > > Tom Ogilvy
    > > > >
    > > > >
    > > > > "Josh O." <[email protected]> wrote in message
    > > > > news:[email protected]...
    > > > > > I have a sheet that contains rows with customer numbers:
    > > > > > 847300001
    > > > > > 847300001
    > > > > > 847300020
    > > > > > 847300015
    > > > > > 847300015
    > > > > > 847300015
    > > > > > 847300002...
    > > > > >
    > > > > > What I need to do is a blank row after each groups of numbers:
    > > > > > 847300001
    > > > > > 847300001
    > > > > >
    > > > > > 847300020
    > > > > >
    > > > > > 847300015
    > > > > > 847300015
    > > > > > 847300015
    > > > > >
    > > > > > 847300002...
    > > > > >
    > > > > > The numbers will change each time I run the report. Any way I can

    do
    > > > > this?
    > > > > >
    > > > >
    > > > >
    > > > >

    > >
    > > --
    > >
    > > Dave Peterson
    > >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1