User Range selection

jtodd

Board Regular
Joined
Aug 4, 2014
Messages
194
Hi
Two things - in the below code . I have just recorded a macro to get this .
1, Is there a neater why to do this and
2, The start cell is static but the to cell can vary (j2 static. j50 can vary ) is there a way to acheive this with out having to alter the code every time.

Sheets("Sheet2").Select
Range("J2:J50").Select
Selection.Copy
Sheets("SPW Schedule").Select
Range("A3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Sheet2").Select
Range("H2:H50").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("SPW Schedule").Select
Range("D3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Are J50 & H50 the last used cells in those columns?
 
Upvote 0
If the answer to the above is yes try
Code:
With Sheets("Sheet2")
   .Range("J2", .Range("J" & Rows.Count).End(xlUp)).Copy
   Sheets("SPW Schedule").Range("A3").PasteSpecial xlPasteValues
   .Range("H2", .Range("H" & Rows.Count).End(xlUp)).Copy
   Sheets("SPW Schedule").Range("D3").PasteSpecial xlPasteValues
End With
Application.CutCopyMode = False
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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