Hi. I am having trouble with some VBA code that asks for an order number and then uses the order number reply to file a copy of a worksheet into a workbook on a network (rather than my hard drive). The code I have currently is this:
Dim CurrentOrder As String
CurrentOrder = Inputbox("what is the current order number?", "Order Number")
Sheets("Sheet1").Select
Sheets("Sheet1").Copy After:=Workbooks("pathname & CurrentOrder").Sheets(8)
I would then like to rename the worksheet created in the network file with some text another variable something like this:
Sheets("Sheet1 (2)").Select
Sheets("Sheet1 (2)").Name = "ABC &Variable"
I get a run time error (9) subscript out of range on the underlined code which doesn't allow the rest of the code to operate so I don't know if the code to rename works either.
Can anyone point out where I have gone wrong?
Thanks
Paul
Dim CurrentOrder As String
CurrentOrder = Inputbox("what is the current order number?", "Order Number")
Sheets("Sheet1").Select
Sheets("Sheet1").Copy After:=Workbooks("pathname & CurrentOrder").Sheets(8)
I would then like to rename the worksheet created in the network file with some text another variable something like this:
Sheets("Sheet1 (2)").Select
Sheets("Sheet1 (2)").Name = "ABC &Variable"
I get a run time error (9) subscript out of range on the underlined code which doesn't allow the rest of the code to operate so I don't know if the code to rename works either.
Can anyone point out where I have gone wrong?
Thanks
Paul