Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Set worksheet.

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Set worksheet.

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Set worksheet.

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Set worksheet.

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Set worksheet.

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Set worksheet.

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
automatically appending newly added data on worksheet to a master list worksheet tabylee via OfficeKB.com Links and Linking in Excel 0 December 17th 09 04:24 PM
Unable to Insert Worksheet/Move and copy worksheet Excel 2003 lukerush Excel Worksheet Functions 2 September 7th 06 05:05 PM
Upload multiple text files into 1 excel worksheet + put the filename as the first column in the worksheet Aster Excel Worksheet Functions 3 March 12th 06 09:58 AM
copy range on every worksheet (diff names) to a master worksheet (to be created) Bernie[_3_] Excel Programming 0 September 22nd 04 03:26 PM
Attaching a JET database to an Excel Worksheet OR storing large binary data in a worksheet Ant Waters Excel Programming 1 September 3rd 03 11:34 AM


All times are GMT +1. The time now is 12:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"