Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Error on select statement

I am working in Excel 97 and am getting a 1004 error - Application defined or
object defined error. The code is

Worksheets(strWrkSht).Range(Cells(2, 2), Cells(intCopyTo1,
intCopyTo)).Select

I have stepped through the code to determine the value of the variables:

intCopyTo1=211
intCopyTo = 6
strWrkSht=Master

All variables are accurate. Any help would be appreciated.
--
M. Shipp
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Error on select statement

Try putting Master in quotes i.e. strWrkSht = "Master"

"SHIPP" wrote:

I am working in Excel 97 and am getting a 1004 error - Application defined or
object defined error. The code is

Worksheets(strWrkSht).Range(Cells(2, 2), Cells(intCopyTo1,
intCopyTo)).Select

I have stepped through the code to determine the value of the variables:

intCopyTo1=211
intCopyTo = 6
strWrkSht=Master

All variables are accurate. Any help would be appreciated.
--
M. Shipp

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Error on select statement

That didn't work. Any additional help is greatly appreciated.

"Bob" wrote:

Try putting Master in quotes i.e. strWrkSht = "Master"

"SHIPP" wrote:

I am working in Excel 97 and am getting a 1004 error - Application defined or
object defined error. The code is

Worksheets(strWrkSht).Range(Cells(2, 2), Cells(intCopyTo1,
intCopyTo)).Select

I have stepped through the code to determine the value of the variables:

intCopyTo1=211
intCopyTo = 6
strWrkSht=Master

All variables are accurate. Any help would be appreciated.
--
M. Shipp

  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Error on select statement

I get this same error message if I try to run the macro while the active
worksheet is other than Master ( I think the select method only works on the
active workbook).

"SHIPP" wrote:

That didn't work. Any additional help is greatly appreciated.

"Bob" wrote:

Try putting Master in quotes i.e. strWrkSht = "Master"

"SHIPP" wrote:

I am working in Excel 97 and am getting a 1004 error - Application defined or
object defined error. The code is

Worksheets(strWrkSht).Range(Cells(2, 2), Cells(intCopyTo1,
intCopyTo)).Select

I have stepped through the code to determine the value of the variables:

intCopyTo1=211
intCopyTo = 6
strWrkSht=Master

All variables are accurate. Any help would be appreciated.
--
M. Shipp

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Error on select statement

You can only select a range if its worksheet is active/selected.

so one way...

with worksheets(strWrkSht)
.select
.range(.cells(2,2),.cells(intCopyTo1,intCopyTo)).s elect
end with

But maybe you could just do what ever you had to do to that range without
selecting it:

with worksheets(strWrkSht)
'.select
.range(.cells(2,2),.cells(intCopyTo1,intCopyTo)).c learcontents
end with


Note the additional dots in front of the .cells(). This means that this object
belongs to the object in the previous With statement.


SHIPP wrote:

I am working in Excel 97 and am getting a 1004 error - Application defined or
object defined error. The code is

Worksheets(strWrkSht).Range(Cells(2, 2), Cells(intCopyTo1,
intCopyTo)).Select

I have stepped through the code to determine the value of the variables:

intCopyTo1=211
intCopyTo = 6
strWrkSht=Master

All variables are accurate. Any help would be appreciated.
--
M. Shipp


--

Dave Peterson
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
Select Case Statement Katie Excel Worksheet Functions 13 December 1st 08 07:32 PM
If Statement to select a letter Karl Excel Worksheet Functions 3 February 8th 08 04:01 PM
SELECT statement Tom Ogilvy Excel Programming 2 July 23rd 04 06:24 PM
SQL Select statement with Date as Pepe[_2_] Excel Programming 3 February 4th 04 06:50 PM
Adding SQL Select Statement Pepe[_2_] Excel Programming 1 January 29th 04 02:19 AM


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

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

About Us

"It's about Microsoft Excel"