Consulting

Results 1 to 4 of 4

Thread: Copy two ranges in one row to the one below, same format if possible... Little help?!

  1. #1
    VBAX Newbie
    Joined
    Dec 2013
    Location
    London Town
    Posts
    2
    Location

    Copy two ranges in one row to the one below, same format if possible... Little help?!

    Evening all
    i've been a lurker here for a while and up til now have always found the answers to my fumbling questions in this forum or the mrexcel one.


    Ive hit a stumbling block and am in need of a guide, I normally scratch by with macros recorded and lightly edited in VBA but am tapped out and need a bit of a hand.


    I have a sheet with columns "A" to "GP" inclusive, colleagues fill this in and on occasion need to add pretty much the same data a second time in the next row down.


    So to take this into account, I need a macro or bit of VBA wizardry to copy the range "A" to "AM" and "GB" to "GP" into the row below the one that has just filled in at the click of a button...


    i have managed to get this to work with copying a complete row but need it to just cut and paste the two ranges.


    I'm hoping that someone might be able to assist.


    Cheers in advance

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    welcome to VBAX.

    if you want to move all values starting at row 2 (excluding header in row 1) in Column A to first blank cell and down in Column AM (and GB to GP), try this.

    insert a activex command button. double click it to view worksheet'd code module and paste the code below.

    Private Sub CommandButton1_Click()
    
        With Worksheets("Sheet1") 'change to suit
            .Range("A2:A" & .Cells(.Rows.Count, "A").End(xlUp).Row).Cut .Range("AM" & .Rows.Count).End(xlUp).Offset(1)
            .Range("GB2:GB" & .Cells(.Rows.Count, "GB").End(xlUp).Row).Cut .Range("GP" & .Rows.Count).End(xlUp).Offset(1)
        End With
    
    End Sub
    a file is attached to demonstrate the above scenario.
    Attached Files Attached Files
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Newbie
    Joined
    Dec 2013
    Location
    London Town
    Posts
    2
    Location
    AWESOME! I will give this a bash and let you know how I go, you're a scholar and a gent Mancubus!

  4. #4
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    welcome. i hope it works for you. if not, it's easy to modify the code.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

Tags for this Thread

Posting Permissions

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