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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,816
Office Version
  1. 2010
Platform
  1. Windows
It seems unlikely that you have a workbook with the extension xls1
 
Last edited:

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Shouldn't it be?

Code:
Workbooks("trybook[2].xlsx").Activate
 

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
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:

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650

ADVERTISEMENT

What error message and on which line of code? Shouldn't it be Cells(1,1)?
 

shg

MrExcel MVP
Joined
May 7, 2008
Messages
21,816
Office Version
  1. 2010
Platform
  1. Windows
How about just Workbooks("trybook 2 .xls").Activate ?
 

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875

ADVERTISEMENT

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:

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Why the space? Try

Code:
Workbooks("trybook 2.xls").Activate
 

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
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:

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
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:

Forum statistics

Threads
1,144,628
Messages
5,725,378
Members
422,622
Latest member
Paranthem

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
Top