Please check my code. Getting runtime error 9. Subcript out of range

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Code:
sub try()
Windows("trybook[2].xls1").Activate
cells(1).select
 
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
It seems unlikely that you have a workbook with the extension xls1
 
Last edited:
Upvote 0
Hi Vog, hi shg4421....!!!!

I run this code and cells(1).value now is "trybook 2 .xls".

Code:
Sub try()
Cells(1).Value = ActiveWorkbook.Name
End Sub


I also want to add that this file is not saved in my desktop/computer, it opens up from web and then I am trying to get the data from trybook2 to book1.

Please help. I am still getting error message.

Thanks;)


I also tried Workbooks("trybook 2 .xls*").Activate but does not work. is this because this file is not saved in the desktop?
 
Last edited:
Upvote 0
What error message and on which line of code? Shouldn't it be Cells(1,1)?
 
Upvote 0
How about just Workbooks("trybook 2 .xls").Activate ?
 
Upvote 0
I have tried that way as well. And Vog, I am getting error in blue hilighted area
Code:
sub try()
[COLOR=blue]Windows("trybook 2 .xls").Activate[/COLOR]
Cells(1).select
End Sub
I am not sure why I am getting this error.
I have tried reseaching on othersites too but did not get a usefull one.:biggrin:


Thanks again. Sorry got busy with the work & couldnt reply back soon.

Once again thanks for helping!;)
 
Last edited:
Upvote 0
The gap is because I do not have access to change the name of the book::biggrin:
Do I have to add something like dim workbook as .....

I have no idea....
 
Last edited:
Upvote 0
Trying this way but still getting same error....
I have my old file in web for perfect example
http://www.box.net/shared/4ohcogad68
I open the link, open the file but did not save it to the desktop and I'm tryin to get the data across to Try.xlsm

Please do try this example and see if same thing happens to you...
Maybe I'm doing a small thing wrong which is why it is not working...


Thanks again
Code:
Sub try2()
Dim wb As Workbook, myfile As String
 
'i also tried "Workbooks("For Pedie(1).xls").Activate" this way but still same error message...
    Windows("For Pedie(1).xls").Activate
    Range("A1").Copy
    'Try.xlsm is in my desktop
    Windows("Try.xlsm").Activate
    Cells(1).Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
End Sub

Vog, thank you so much again. I dont mean to trouble you this far....:)
I'll be fine...whenever you're free please try it out and see if you can make it work.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,625
Messages
6,120,598
Members
448,973
Latest member
ksonnia

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