Copy specific cells from row dependant on cell entry

manmah

Board Regular
Joined
May 11, 2009
Messages
70
Hi there, I've got a bit of headache with my current spreadsheet. I have built a sheet using VBA where the final outcome is a table. This can go from row 1 to anywhere, (normally no more than 60). What I would like to do now is be able to enter 1,2,3,4 etc into column A and initiate a macro to copy certain cells from those rows, for example:
1 in A5 would copy cells D5:H5 and paste into cells A4:E4 in sheet 2; 2 in A8 would copy cells D8:H8 to cells A4:E4 in sheet 3 etc. I have tried many things but appear to have hit a wall. I have managed to copy the entire row but this is no good.
Thanks in advance.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Below is the code I have managed to suss out but I just need help with choosing the specific cells from the selected row instead of entire row? Also I have set this up to find numbers 1 to 7 so the below code is duplicated for each one but if for example I only have numbers 1 to 4 in the macro is copying the line numbered 4 into 4,5,6 and 7. This is not a major problem but if anyone can help I would be grateful. Thank you.

Code:
[FONT=Times New Roman][SIZE=3][COLOR=#000000]  [/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000]Sub copydims1()[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]  [/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000]    [/COLOR][/SIZE][SIZE=3][COLOR=#000000]Dim c As Range[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]  [/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000]    [/COLOR][/SIZE][SIZE=3][COLOR=#000000]Dim SrchRng[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]  [/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000]   [/COLOR][/SIZE][SIZE=3][COLOR=#000000] [/COLOR][/SIZE][SIZE=3][COLOR=#000000]Set SrchRng = ActiveSheet.Range("A1", ActiveSheet.Range("A65536").End(xlUp))[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]  [/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000]    [/COLOR][/SIZE][SIZE=3][COLOR=#000000]Set c = SrchRng.Find("1", LookIn:=xlValues)[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]  [/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000]        [/COLOR][/SIZE][SIZE=3][COLOR=#000000]If Not c Is Nothing Then c.EntireRow.copy[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]  [/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000] [/COLOR][/SIZE][SIZE=3][COLOR=#000000]  [/COLOR][/SIZE][SIZE=3][COLOR=#000000] [/COLOR][/SIZE][SIZE=3][COLOR=#000000]Sheets("DIM SHEET 1").Select[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]  [/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000]    [/COLOR][/SIZE][SIZE=3][COLOR=#000000]Range("A7").Select[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]  [/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000]    [/COLOR][/SIZE][SIZE=3][COLOR=#000000]ActiveSheet.Paste[/COLOR][/SIZE][SIZE=3][COLOR=#000000]  [/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]  [/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000]Sheets(“BOOKING SHEET”).select[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]  [/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000]Call copydims2[/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]  [/COLOR][/SIZE][/FONT][FONT=Calibri][SIZE=3][COLOR=#000000]End sub[/COLOR][/SIZE][SIZE=3][COLOR=#000000]    [/COLOR][/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3][COLOR=#000000]  [CO[/COLOR][/SIZE][/FONT]DE]
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,301
Members
449,078
Latest member
nonnakkong

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top