Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have tried everything and the following statement always gives me an error:
Dim wks As Worksheet Set wks = Sheets("Columns") I have an .xls file that has some tabs in it for each "sheet". It turns out that Sheet3 is named by the tab "Columns". I was expecting to be able to access this sheet starting with the above statement. But the statement always throws an error Runtime error '1004': Method 'Sheets' of object '_Global' failed Why is it failing? How do I find out? Is this the correct syntax? Thank you. Kevin |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If "Columns" was mis-spelled you would get a subscript out of range error.
Is the code in a module and not worksheet code? -- Gary''s Student "Kevin Burton" wrote: I have tried everything and the following statement always gives me an error: Dim wks As Worksheet Set wks = Sheets("Columns") I have an .xls file that has some tabs in it for each "sheet". It turns out that Sheet3 is named by the tab "Columns". I was expecting to be able to access this sheet starting with the above statement. But the statement always throws an error Runtime error '1004': Method 'Sheets' of object '_Global' failed Why is it failing? How do I find out? Is this the correct syntax? Thank you. Kevin |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The only error that I am getting is the 1004 error. The dialog box doesn't
indicate anything about subscript out of range. It is almost like this is not compiled in the right environment. How do I tell if the code is in a module or worksheet? I click on 'Macros' and 'Create' then I paste in the code. Is this worksheet code? Thank you for your help. "Gary''s Student" wrote: If "Columns" was mis-spelled you would get a subscript out of range error. Is the code in a module and not worksheet code? -- Gary''s Student "Kevin Burton" wrote: I have tried everything and the following statement always gives me an error: Dim wks As Worksheet Set wks = Sheets("Columns") I have an .xls file that has some tabs in it for each "sheet". It turns out that Sheet3 is named by the tab "Columns". I was expecting to be able to access this sheet starting with the above statement. But the statement always throws an error Runtime error '1004': Method 'Sheets' of object '_Global' failed Why is it failing? How do I find out? Is this the correct syntax? Thank you. Kevin |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
put this in a standard module, not a sheet module
Option Explicit Dim wks As Worksheet Sub w() Set wks = Worksheets("Columns") wks.Activate Range("a5").Select End Sub -- Gary "Kevin Burton" wrote in message ... I have tried everything and the following statement always gives me an error: Dim wks As Worksheet Set wks = Sheets("Columns") I have an .xls file that has some tabs in it for each "sheet". It turns out that Sheet3 is named by the tab "Columns". I was expecting to be able to access this sheet starting with the above statement. But the statement always throws an error Runtime error '1004': Method 'Sheets' of object '_Global' failed Why is it failing? How do I find out? Is this the correct syntax? Thank you. Kevin |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry for my ignorance but what is a standard module and what is a sheet
module. I just clicked on 'Macros' then 'Create' "Gary Keramidas" wrote: put this in a standard module, not a sheet module Option Explicit Dim wks As Worksheet Sub w() Set wks = Worksheets("Columns") wks.Activate Range("a5").Select End Sub -- Gary "Kevin Burton" wrote in message ... I have tried everything and the following statement always gives me an error: Dim wks As Worksheet Set wks = Sheets("Columns") I have an .xls file that has some tabs in it for each "sheet". It turns out that Sheet3 is named by the tab "Columns". I was expecting to be able to access this sheet starting with the above statement. But the statement always throws an error Runtime error '1004': Method 'Sheets' of object '_Global' failed Why is it failing? How do I find out? Is this the correct syntax? Thank you. Kevin |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
that's a module. if you right click a sheetname and choose view code, that's
sheet code. also, if you're in vb, you will see the sheets listed under vba project on the left. if you have modules, they will be listed at the bottom of the list, under modules. -- Gary "Kevin Burton" wrote in message ... Sorry for my ignorance but what is a standard module and what is a sheet module. I just clicked on 'Macros' then 'Create' "Gary Keramidas" wrote: put this in a standard module, not a sheet module Option Explicit Dim wks As Worksheet Sub w() Set wks = Worksheets("Columns") wks.Activate Range("a5").Select End Sub -- Gary "Kevin Burton" wrote in message ... I have tried everything and the following statement always gives me an error: Dim wks As Worksheet Set wks = Sheets("Columns") I have an .xls file that has some tabs in it for each "sheet". It turns out that Sheet3 is named by the tab "Columns". I was expecting to be able to access this sheet starting with the above statement. But the statement always throws an error Runtime error '1004': Method 'Sheets' of object '_Global' failed Why is it failing? How do I find out? Is this the correct syntax? Thank you. Kevin |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
automatically appending newly added data on worksheet to a master list worksheet | Links and Linking in Excel | |||
Unable to Insert Worksheet/Move and copy worksheet Excel 2003 | Excel Worksheet Functions | |||
Upload multiple text files into 1 excel worksheet + put the filename as the first column in the worksheet | Excel Worksheet Functions | |||
copy range on every worksheet (diff names) to a master worksheet (to be created) | Excel Programming | |||
Attaching a JET database to an Excel Worksheet OR storing large binary data in a worksheet | Excel Programming |