Copy Variable Range To Next Blank Row

  • Hello,


    I did some research on the site and found help for people with similar problems, but sadly wasnt quite smart enough to apply those answers to my problem.


    I want to be able to add new accounts in the New Account Input sheet (consistent of names and number) and then push a button to paste them in the next free row on Account master.


    I do know how to assign a macro to a button - its just the actual vb coding Im struggling with.


    Thanks,
    Tim

  • Re: Macro To Copy To Next Blank Row


    Try this:

    Code
    Sub Move_New_Account()
    Dim Rng As Range, MyCell As Range, Rng1 As Range
    Set Rng = Sheets("Account Input").Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
    Set Rng1 = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
    Rng.EntireRow.Copy Destination:=Rng1
    End Sub
  • Re: Macro To Copy To Next Blank Row


    This should get you started:


  • Re: Copy Variable Range To Next Blank Row


    Awesome!


    Those both work well - but question - if I want it to cut and paste as opposed to copy what do I need to change?


    Also - just to help me better understand if you dont mind...


    1. what does vbnullstring mean/do?
    2. what does x1Down do?


    Thanks a ton!

  • Re: Copy Variable Range To Next Blank Row


    You wouldn't want to cut and paste just add Rng.Clearcontents to the end of my code before end sub. as for the others highlight them in the VBE then hit F1

  • Re: Copy Variable Range To Next Blank Row


    Quote

    if I want it to cut and paste as opposed to copy what do I need to change?


    Amended code:


    Quote

    1. what does vbnullstring mean/do?


    Basically, just checks to make sure the cell is not empty. As "Simon says" (OK, bad pun, but I couldn't help it. :grin:), press F1 in the VB Editor to read the help on this.

    Quote

    2. what does x1Down do?


    Selects the cell at the bottom of column A in the region that contains cell A1.

  • Re: Copy Variable Range To Next Blank Row


    I tried it and it awesome.
    however, if i use it on excel with group outline (collapse mode) the script is not work.
    Attached with sample file for ref. You will get what i mean before and after you add new table between expand mode and collapse mode.
    Appreciate your help to solve this problem. :)


    Thank you.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!