+ Reply to Thread
Results 1 to 5 of 5

macro to insert rows b/t selected data!!

  1. #1
    Registered User
    Join Date
    01-15-2009
    Location
    North Carolina
    MS-Off Ver
    Excel 2003
    Posts
    24

    macro to insert rows b/t selected data!!

    Hi all. This is my first post to this forum. I am looking forward to hopefully learning something and contributing to the group as well.

    My question is this:

    I have a need for a macro that will insert anywhere from 1-5 blanks rows b/t selected data in a spreadsheet.

    The code I have written so far works... sort of. Ha

    The problem is that my current attempt inserts the # of rows between ALL data and not the selection. I do not know the call to make this work so any info would be much appreciated.

    Just to let you all know I want the user to be able to enter the # of rows they need into a message/input box. As of now I have it setup as a userform with a textbox, but I am flexible with that.


    Code follows:

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 01-15-2009 at 03:36 PM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    I have a need for a macro that will insert anywhere from 1-5 blanks rows b/t selected data in a spreadsheet.
    Not sure what you mean by this. Does it matter how many rows are selected? Do you mean insert the given number of rows between each pair of rows in the selection?

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Here's a simple way

    Please Login or Register  to view this content.
    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Registered User
    Join Date
    01-15-2009
    Location
    North Carolina
    MS-Off Ver
    Excel 2003
    Posts
    24

    lets try that again..

    Stephen: That is exactly what I need. Sorry if I didnt explain it very well. Let me try again.

    I want to the user to be able to select between 1-5. And depending on that entry the macro will insert the corresponding number of blank rows between each row of the current selection.

    ie. 5 rows of data in worksheet
    aaaaa
    bbbbb
    ccccc
    ddddd
    eeeee

    *The user has the first 3 selected and runs the macro to insert 1 row. The output should be something like this:

    aaaaa

    bbbbb

    ccccc

    ddddd
    eeeee


    Hope that somewhat clears it up! Thanks again all!

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    Building on VBA Noob's suggestion, I think this works:
    Please Login or Register  to view this content.

+ 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