using dim range as range in address string

moxy85

Board Regular
Joined
Nov 25, 2009
Messages
57
I have the following code as part of my macro whereby I want the user to select the "schedulenumber" by way of cell address and then the macro work out the range of data to copy from this address.

Therefore I have come up with the following but something's not right, can you help me please?

Code:
    Sheets(strActiveSheet).Select
    Dim schedulenumber As Range
    Set schedulenumber = Application.InputBox _
    (Prompt:="Select schedule numebr", Title:="Schedule Number", Type:=8)
 
    ActiveSheet.Range(Range(schedulenumber.Offset(2, -1)), Range(L65536).End(xlUp)).Copy
    Sheets("Order Form - Master (2)").Select
    Range("I17").Select
    Selection.PasteSpecial Paste:=xlPasteValues, _
    Operation:=xlNone, SkipBlanks:=False, Transpose:=False

at the moment for testing, the only cell can be contained within a certain location hence I am able to set the "L65536" location.
Once I correct the first part of the code I aim to replicat this for the second address i.e.

Code:
ActiveSheet.Range(Range(schedulenumber.Offset(2, -1)), Range(schedulenumber.End(xlUp)).Copy

thanks in advance.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I forgot to mention that the line that debugs is

Code:
ActiveSheet.Range(Range(schedulenumber.Offset(2, -1)), Range(L65536).End(xlUp)).Copy
 
Upvote 0
It looks like there's misplaced parenthesis

Rich (BB code):
ActiveSheet.Range(Range(schedulenumber).Offset(2, -1), Range(L65536).End(xlUp)).Copy
 
Upvote 0
that is how I started the code, i've just tried it again and it doesn't work

runtime 1004 error
method 'Range' of object'_global' failed.
 
Upvote 0
With type:=8, the inputbox returns a range object.
Try
Code:
ActiveSheet.Range(schedulenumber.Offset(2, -1), Range(L65536).End(xlUp)).Copy
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

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