Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default A '.Select' question

I have recently restructured code in a routine and within the
new code, now have added a check for sheets to exclude:

For Each ws In ActiveWorkbook.Worksheets
If Not (ws.Name Like "DataStore" Or ws.Name Like "*Architect's
Instructions*" Or _
ws.Name Like "*Variations*" Or ws.Name Like "*Materials*" Or ws.Name
Like _
"*Preliminaries*" Or ws.Name Like "*Summary*" Or ws.Name Like _
"*SUMMARY*" Or ws.Name Like "*MASTER*") Then
With ws
'Find which type of BofQ we are dealing with, and in which column the
'£'
'is found. NB: This routine assumes that '£' will always occur in the
last
'but one column
' .Select
For Each C In Range("A1:Z100")
If C.Value = SEARCHFOR Then
£Col = C.Column
Exit For
End If
Next
End With
End If
Next

After adding the exclude sheet code, I found that £Col was equal to 0, even
when it should have been a different value, and even when Locals showed 'ws'
working with a 'valid' sheet.

So I added ...'.Select'

Now it 'appears' to work. ............why is this, please?

Regards.
(unqualified..again?)



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.528 / Virus Database: 324 - Release Date: 16/10/2003


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default A '.Select' question

Stuart,

My guess is that
For Each C In Range("A1:Z100")
If C.Value = SEARCHFOR Then
£Col = C.Column
Exit For
End If
Next

isn't finding anything...

Is SEARCHFOR a variable or a text string?
If it is a text string than it should be "SEARCHFOR" (in quotes).

--
sb
"Stuart" wrote in message
...
I have recently restructured code in a routine and within the
new code, now have added a check for sheets to exclude:

For Each ws In ActiveWorkbook.Worksheets
If Not (ws.Name Like "DataStore" Or ws.Name Like "*Architect's
Instructions*" Or _
ws.Name Like "*Variations*" Or ws.Name Like "*Materials*" Or

ws.Name
Like _
"*Preliminaries*" Or ws.Name Like "*Summary*" Or ws.Name Like _
"*SUMMARY*" Or ws.Name Like "*MASTER*") Then
With ws
'Find which type of BofQ we are dealing with, and in which column

the
'£'
'is found. NB: This routine assumes that '£' will always occur in

the
last
'but one column
' .Select
For Each C In Range("A1:Z100")
If C.Value = SEARCHFOR Then
£Col = C.Column
Exit For
End If
Next
End With
End If
Next

After adding the exclude sheet code, I found that £Col was equal to 0,

even
when it should have been a different value, and even when Locals showed

'ws'
working with a 'valid' sheet.

So I added ...'.Select'

Now it 'appears' to work. ............why is this, please?

Regards.
(unqualified..again?)



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.528 / Virus Database: 324 - Release Date: 16/10/2003




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default A '.Select' question

Apologies for the linewrap.
SEARCHFOR is dimmed as follows:
Const SEARCHFOR As Variant = "£"

Thanks and Regards.

"steve" wrote in message
...
Stuart,

My guess is that
For Each C In Range("A1:Z100")
If C.Value = SEARCHFOR Then
£Col = C.Column
Exit For
End If
Next

isn't finding anything...

Is SEARCHFOR a variable or a text string?
If it is a text string than it should be "SEARCHFOR" (in quotes).

--
sb
"Stuart" wrote in message
...
I have recently restructured code in a routine and within the
new code, now have added a check for sheets to exclude:

For Each ws In ActiveWorkbook.Worksheets
If Not (ws.Name Like "DataStore" Or ws.Name Like "*Architect's
Instructions*" Or _
ws.Name Like "*Variations*" Or ws.Name Like "*Materials*" Or

ws.Name
Like _
"*Preliminaries*" Or ws.Name Like "*Summary*" Or ws.Name Like _
"*SUMMARY*" Or ws.Name Like "*MASTER*") Then
With ws
'Find which type of BofQ we are dealing with, and in which column

the
'£'
'is found. NB: This routine assumes that '£' will always occur in

the
last
'but one column
' .Select
For Each C In Range("A1:Z100")
If C.Value = SEARCHFOR Then
£Col = C.Column
Exit For
End If
Next
End With
End If
Next

After adding the exclude sheet code, I found that £Col was equal to 0,

even
when it should have been a different value, and even when Locals showed

'ws'
working with a 'valid' sheet.

So I added ...'.Select'

Now it 'appears' to work. ............why is this, please?

Regards.
(unqualified..again?)



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.528 / Virus Database: 324 - Release Date: 16/10/2003






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.528 / Virus Database: 324 - Release Date: 16/10/2003


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default A '.Select' question

For Each ws In ActiveWorkbook.Worksheets
If Not (ws.Name Like "DataStore" Or ws.Name Like "*Architect's
Instructions*" Or _
ws.Name Like "*Variations*" Or ws.Name Like "*Materials*" Or ws.Name
Like _
"*Preliminaries*" Or ws.Name Like "*Summary*" Or ws.Name Like _
"*SUMMARY*" Or ws.Name Like "*MASTER*") Then
With ws
'Find which type of BofQ we are dealing with, and in which column the
'£'
'is found. NB: This routine assumes that '£' will always occur in the
last
'but one column
' .Select
For Each C In Range("A1:Z100") '<== ther is no period here
' so this refers to the active sheet - your WITH is doing nothing
' change to .Range("A1:Z100") and you won't need to select
If C.Value = SEARCHFOR Then
£Col = C.Column
Exit For
End If
Next
End With
End If
Next


--
Regards,
Tom Ogilvy

Stuart wrote in message
...
I have recently restructured code in a routine and within the
new code, now have added a check for sheets to exclude:

For Each ws In ActiveWorkbook.Worksheets
If Not (ws.Name Like "DataStore" Or ws.Name Like "*Architect's
Instructions*" Or _
ws.Name Like "*Variations*" Or ws.Name Like "*Materials*" Or

ws.Name
Like _
"*Preliminaries*" Or ws.Name Like "*Summary*" Or ws.Name Like _
"*SUMMARY*" Or ws.Name Like "*MASTER*") Then
With ws
'Find which type of BofQ we are dealing with, and in which column

the
'£'
'is found. NB: This routine assumes that '£' will always occur in

the
last
'but one column
' .Select
For Each C In Range("A1:Z100")
If C.Value = SEARCHFOR Then
£Col = C.Column
Exit For
End If
Next
End With
End If
Next

After adding the exclude sheet code, I found that £Col was equal to 0,

even
when it should have been a different value, and even when Locals showed

'ws'
working with a 'valid' sheet.

So I added ...'.Select'

Now it 'appears' to work. ............why is this, please?

Regards.
(unqualified..again?)



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.528 / Virus Database: 324 - Release Date: 16/10/2003




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default A '.Select' question

Missed it.

Regards and thanks.

"Tom Ogilvy" wrote in message
...
For Each ws In ActiveWorkbook.Worksheets
If Not (ws.Name Like "DataStore" Or ws.Name Like "*Architect's
Instructions*" Or _
ws.Name Like "*Variations*" Or ws.Name Like "*Materials*" Or

ws.Name
Like _
"*Preliminaries*" Or ws.Name Like "*Summary*" Or ws.Name Like _
"*SUMMARY*" Or ws.Name Like "*MASTER*") Then
With ws
'Find which type of BofQ we are dealing with, and in which column

the
'£'
'is found. NB: This routine assumes that '£' will always occur in

the
last
'but one column
' .Select
For Each C In Range("A1:Z100") '<== ther is no period here
' so this refers to the active sheet - your WITH is doing nothing
' change to .Range("A1:Z100") and you won't need to select
If C.Value = SEARCHFOR Then
£Col = C.Column
Exit For
End If
Next
End With
End If
Next


--
Regards,
Tom Ogilvy

Stuart wrote in message
...
I have recently restructured code in a routine and within the
new code, now have added a check for sheets to exclude:

For Each ws In ActiveWorkbook.Worksheets
If Not (ws.Name Like "DataStore" Or ws.Name Like "*Architect's
Instructions*" Or _
ws.Name Like "*Variations*" Or ws.Name Like "*Materials*" Or

ws.Name
Like _
"*Preliminaries*" Or ws.Name Like "*Summary*" Or ws.Name Like _
"*SUMMARY*" Or ws.Name Like "*MASTER*") Then
With ws
'Find which type of BofQ we are dealing with, and in which column

the
'£'
'is found. NB: This routine assumes that '£' will always occur in

the
last
'but one column
' .Select
For Each C In Range("A1:Z100")
If C.Value = SEARCHFOR Then
£Col = C.Column
Exit For
End If
Next
End With
End If
Next

After adding the exclude sheet code, I found that £Col was equal to 0,

even
when it should have been a different value, and even when Locals showed

'ws'
working with a 'valid' sheet.

So I added ...'.Select'

Now it 'appears' to work. ............why is this, please?

Regards.
(unqualified..again?)



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.528 / Virus Database: 324 - Release Date: 16/10/2003






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.528 / Virus Database: 324 - Release Date: 16/10/2003




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 All question P D Sterling New Users to Excel 4 August 31st 08 03:53 AM
rows().select VBA question mohavv Excel Discussion (Misc queries) 2 December 2nd 07 06:43 AM
Question with use of advanced filter to select empty cells RAJ Excel Discussion (Misc queries) 5 March 1st 07 03:11 PM
VBA select case question Jeff Excel Discussion (Misc queries) 2 January 27th 06 03:03 AM
Question: Range().Select for more than one row? Hannibal Excel Programming 1 July 15th 03 09:52 AM


All times are GMT +1. The time now is 04:58 PM.

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"