Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default which sheet a loop is valid for-how do you know?

How do I know which sheet the loop refers to / is valid for? According to my
logic it should be previous sheet, but it seems it is the other sheet (start
here)? Not logical as I select the previous sheet just before the loop starts.

Sheets("start here!").Activate
ActiveSheet.Previous.Select

x = 2

Do While Cells(x, 2).Value < ""

Cells(x, 9) = Application.VLookup(Cells(x, 8),
Worksheets("Prognos").Range("A1:B50000"), 2, False)

x = x + 1

Loop

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default which sheet a loop is valid for-how do you know?

In a general module, you would be correct.

I suspect this is in the worksheet module of the sheet "Start Here!" where
unqualified references are to the sheet containing the code, not the
activesheet.

Qualify your references or move the code to a general module and call it
from the worksheet module (if necessary)

--
Regards,
Tom Ogilvy


"sverre" wrote:

How do I know which sheet the loop refers to / is valid for? According to my
logic it should be previous sheet, but it seems it is the other sheet (start
here)? Not logical as I select the previous sheet just before the loop starts.

Sheets("start here!").Activate
ActiveSheet.Previous.Select

x = 2

Do While Cells(x, 2).Value < ""

Cells(x, 9) = Application.VLookup(Cells(x, 8),
Worksheets("Prognos").Range("A1:B50000"), 2, False)

x = x + 1

Loop

End Sub

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
what are the rules for a valid sheet name in excel romstep Excel Discussion (Misc queries) 11 August 25th 09 04:23 AM
2 questions: if-else & sheet loop s80NL Excel Programming 4 July 15th 06 12:37 PM
Ignoring Sheet in For Each Loop ExcelMonkey[_190_] Excel Programming 3 March 3rd 05 10:09 PM
Another loop & sheet question steve Excel Programming 4 November 25th 03 02:12 PM
Excluding sheet in loop david Excel Programming 2 July 31st 03 03:18 AM


All times are GMT +1. The time now is 03:43 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"