Macro to insert rows and duplicate values

  • Hi,

    I have rows of data that relate to hotel reservations - one row per reservation. I would like to split each reservation into one row per night.

    I need a macro which will do the following:

    - Look at value in 'nights' column "n"

    - Insert "n-1" rows beneath row

    - Copy all values into each new row except for one column 'Stay Date'

    - In the first new row 'Stay Date' = check in date + 1

    - In the second new row 'Stay Date' = check in date + 2 etc.

    So far I have the below code which creates the new rows, but I am stuck on populating them.

    Any help would be greatly appreciated!

  • .

    The following macro takes data contained in Sheet #2 in the cells indicated (A2, B2, etc) and saves that as a record (on a single row) in Sheet 3.

    The last line then clears the data from Sheet #2 so a new data can be entered for another record that will be saved below the previous

    record on Sheet #3.

    I believe this is what you are seeking ???

  • Possibly...

    If I've been helpful, let me know. If I haven't, let me know that too.

  • Welcome to the Forum. Please read the Forum Rules to understand how the Forum works and why I have added Code Tags to your post

    All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.Be sure to use them in future posts.

    How to use code tags

    Note: no apostrophe in the tags, just used for demonstration here.


    your code goes between these tags


    Or, just highlight all of the code and press the <> in the post menu above button to add the code tags.