Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default Routine works on first sheet but not second

The code below is the section where I am having trouble. On sheet 1
everything works perfectly. On sheet two, with identical columns "B", the
"Select Method of Range Class Failed" error message pops up at "rng.select".
I replaced that with "Range("B5:B38").select and got the error message at
"strike.activate".

What could make it not work on sheet 2 with Column B identical to that on
Sheet 1?

This is going to cause ulcers. There are four more sheets to run through if
I can ever get it past Sheet 2.


Sheets(type1).Select
Set rng = .Range(.Cells(5, 2), .Cells(5, 2).End(xlDown))
rng.Select

Set strike = .Cells.Find(what:=strike, after:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlDown, _
MatchCase:=False, SearchFormat:=False)
strike.Activate
ActiveCell.Offset(0, 3).Select
Selection.PasteSpecial
strike = strike + 2.5
Loop Until strike 140
Next

strike = 0
type1 = type2
type2 = type3
type3 = type4
type4 = type5
type5 = type6
shtype = type1
Next

--
Best wishes,

Jim
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Routine works on first sheet but not second

Where is your with statement and what does it say?

Charles
Jim Jackson wrote:
The code below is the section where I am having trouble. On sheet 1
everything works perfectly. On sheet two, with identical columns "B", the
"Select Method of Range Class Failed" error message pops up at "rng.select".
I replaced that with "Range("B5:B38").select and got the error message at
"strike.activate".

What could make it not work on sheet 2 with Column B identical to that on
Sheet 1?

This is going to cause ulcers. There are four more sheets to run through if
I can ever get it past Sheet 2.


Sheets(type1).Select
Set rng = .Range(.Cells(5, 2), .Cells(5, 2).End(xlDown))
rng.Select

Set strike = .Cells.Find(what:=strike, after:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlDown, _
MatchCase:=False, SearchFormat:=False)
strike.Activate
ActiveCell.Offset(0, 3).Select
Selection.PasteSpecial
strike = strike + 2.5
Loop Until strike 140
Next

strike = 0
type1 = type2
type2 = type3
type3 = type4
type4 = type5
type5 = type6
shtype = type1
Next

--
Best wishes,

Jim


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default Routine works on first sheet but not second

The With statement says "With Cells" and I bet it should say "With Sheets".
--
Best wishes,

Jim


"Die_Another_Day" wrote:

Where is your with statement and what does it say?

Charles
Jim Jackson wrote:
The code below is the section where I am having trouble. On sheet 1
everything works perfectly. On sheet two, with identical columns "B", the
"Select Method of Range Class Failed" error message pops up at "rng.select".
I replaced that with "Range("B5:B38").select and got the error message at
"strike.activate".

What could make it not work on sheet 2 with Column B identical to that on
Sheet 1?

This is going to cause ulcers. There are four more sheets to run through if
I can ever get it past Sheet 2.


Sheets(type1).Select
Set rng = .Range(.Cells(5, 2), .Cells(5, 2).End(xlDown))
rng.Select

Set strike = .Cells.Find(what:=strike, after:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlDown, _
MatchCase:=False, SearchFormat:=False)
strike.Activate
ActiveCell.Offset(0, 3).Select
Selection.PasteSpecial
strike = strike + 2.5
Loop Until strike 140
Next

strike = 0
type1 = type2
type2 = type3
type3 = type4
type4 = type5
type5 = type6
shtype = type1
Next

--
Best wishes,

Jim



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Routine works on first sheet but not second

I think the With statement needs to be after the Sheets(type1).Select
Statement. Otherwise I think you are still trying to tell excel
Sheet1.Cells. Let me know if that helps

Charles

Jim Jackson wrote:
The With statement says "With Cells" and I bet it should say "With Sheets".
--
Best wishes,

Jim


"Die_Another_Day" wrote:

Where is your with statement and what does it say?

Charles
Jim Jackson wrote:
The code below is the section where I am having trouble. On sheet 1
everything works perfectly. On sheet two, with identical columns "B", the
"Select Method of Range Class Failed" error message pops up at "rng.select".
I replaced that with "Range("B5:B38").select and got the error message at
"strike.activate".

What could make it not work on sheet 2 with Column B identical to that on
Sheet 1?

This is going to cause ulcers. There are four more sheets to run through if
I can ever get it past Sheet 2.


Sheets(type1).Select
Set rng = .Range(.Cells(5, 2), .Cells(5, 2).End(xlDown))
rng.Select

Set strike = .Cells.Find(what:=strike, after:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlDown, _
MatchCase:=False, SearchFormat:=False)
strike.Activate
ActiveCell.Offset(0, 3).Select
Selection.PasteSpecial
strike = strike + 2.5
Loop Until strike 140
Next

strike = 0
type1 = type2
type2 = type3
type3 = type4
type4 = type5
type5 = type6
shtype = type1
Next

--
Best wishes,

Jim




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default Routine works on first sheet but not second

That change made it work. Thanks for the "Wake up call."
--
Best wishes,

Jim


"Jim Jackson" wrote:

The With statement says "With Cells" and I bet it should say "With Sheets".
--
Best wishes,

Jim


"Die_Another_Day" wrote:

Where is your with statement and what does it say?

Charles
Jim Jackson wrote:
The code below is the section where I am having trouble. On sheet 1
everything works perfectly. On sheet two, with identical columns "B", the
"Select Method of Range Class Failed" error message pops up at "rng.select".
I replaced that with "Range("B5:B38").select and got the error message at
"strike.activate".

What could make it not work on sheet 2 with Column B identical to that on
Sheet 1?

This is going to cause ulcers. There are four more sheets to run through if
I can ever get it past Sheet 2.


Sheets(type1).Select
Set rng = .Range(.Cells(5, 2), .Cells(5, 2).End(xlDown))
rng.Select

Set strike = .Cells.Find(what:=strike, after:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlDown, _
MatchCase:=False, SearchFormat:=False)
strike.Activate
ActiveCell.Offset(0, 3).Select
Selection.PasteSpecial
strike = strike + 2.5
Loop Until strike 140
Next

strike = 0
type1 = type2
type2 = type3
type3 = type4
type4 = type5
type5 = type6
shtype = type1
Next

--
Best wishes,

Jim





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Routine works on first sheet but not second

NP. It's funny that we never see our mistake until we show it to other
programmers :)

Charles
Jim Jackson wrote:
That change made it work. Thanks for the "Wake up call."
--
Best wishes,

Jim


"Jim Jackson" wrote:

The With statement says "With Cells" and I bet it should say "With Sheets".
--
Best wishes,

Jim


"Die_Another_Day" wrote:

Where is your with statement and what does it say?

Charles
Jim Jackson wrote:
The code below is the section where I am having trouble. On sheet 1
everything works perfectly. On sheet two, with identical columns "B", the
"Select Method of Range Class Failed" error message pops up at "rng.select".
I replaced that with "Range("B5:B38").select and got the error message at
"strike.activate".

What could make it not work on sheet 2 with Column B identical to that on
Sheet 1?

This is going to cause ulcers. There are four more sheets to run through if
I can ever get it past Sheet 2.


Sheets(type1).Select
Set rng = .Range(.Cells(5, 2), .Cells(5, 2).End(xlDown))
rng.Select

Set strike = .Cells.Find(what:=strike, after:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlDown, _
MatchCase:=False, SearchFormat:=False)
strike.Activate
ActiveCell.Offset(0, 3).Select
Selection.PasteSpecial
strike = strike + 2.5
Loop Until strike 140
Next

strike = 0
type1 = type2
type2 = type3
type3 = type4
type4 = type5
type5 = type6
shtype = type1
Next

--
Best wishes,

Jim



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
Naming work sheet the name as sub-routine that creates it Rich Mogy Excel Worksheet Functions 5 October 6th 08 02:07 PM
data validation works in one sheet but not another Patrick Riley New Users to Excel 1 April 18th 07 01:30 AM
DATEVALUE works on one sheet, not another Kim Excel Worksheet Functions 4 January 16th 06 05:21 PM
UDF only works when focus is on a specific sheet - Help!! Andibevan[_4_] Excel Programming 3 November 16th 05 01:56 PM
UDF only works when focus is on a specific sheet - Help!! Andibevan[_4_] Excel Programming 0 November 15th 05 09:14 AM


All times are GMT +1. The time now is 11:37 PM.

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"