PDA

View Full Version : [SOLVED:] Copy two ranges in one row to the one below, same format if possible... Little help?!



Mrtnjcksn
12-04-2013, 10:56 AM
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. : pray2:


Cheers in advance

mancubus
12-04-2013, 12:58 PM
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.

Mrtnjcksn
12-04-2013, 01:42 PM
AWESOME! I will give this a bash and let you know how I go, you're a scholar and a gent Mancubus!

mancubus
12-04-2013, 02:34 PM
welcome. i hope it works for you. if not, it's easy to modify the code.