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

I have a loop which loops through sheets and does things. As the loop starts
off, there is a quick test to see if the sheet name of the current sheet
matches a specific name OR if it is already included in a 2D array. If
either of these conditions is TRUE then nothing happens while VBA loops
through it. My code is failing on the Hlookup.

?sh.Name
Audit Results

?AuditShtName
Audit Results

Now the reason the Hlookup is failing is that the the 2D Array does not have
a Audit Results in it. But sometimes it will have it. So when it has it the
code will work, when it doesn't it fails. I need to wrap some error handling
the Hlookup so that when it generates an error it continues. On Error Resume
Next or wrap an Iserror function around it. However I still need to test the
Hlookup. So I do not want an Iserror function result to overide the Hlookup
test. Any ideas?

For each ws in ActiveWorkbook.Worksheets
If sh.Name < AuditShtName Or _
Application.HLookup(sh.Name, WorkSheetSelectForm.SheetExcludeArray,
2, False) = 0 Then
'Do something fun!!!!!
End if
Next

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Hlookup Problem

How about just checking:

iserror(application.hlookup(...))



ExcelMonkey wrote:

I have a loop which loops through sheets and does things. As the loop starts
off, there is a quick test to see if the sheet name of the current sheet
matches a specific name OR if it is already included in a 2D array. If
either of these conditions is TRUE then nothing happens while VBA loops
through it. My code is failing on the Hlookup.

?sh.Name
Audit Results

?AuditShtName
Audit Results

Now the reason the Hlookup is failing is that the the 2D Array does not have
a Audit Results in it. But sometimes it will have it. So when it has it the
code will work, when it doesn't it fails. I need to wrap some error handling
the Hlookup so that when it generates an error it continues. On Error Resume
Next or wrap an Iserror function around it. However I still need to test the
Hlookup. So I do not want an Iserror function result to overide the Hlookup
test. Any ideas?

For each ws in ActiveWorkbook.Worksheets
If sh.Name < AuditShtName Or _
Application.HLookup(sh.Name, WorkSheetSelectForm.SheetExcludeArray,
2, False) = 0 Then
'Do something fun!!!!!
End if
Next

Thanks


--

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
HLOOKUP PROBLEM mmcap Excel Worksheet Functions 4 November 27th 08 03:24 AM
Problem with HLookup. Not sure if it is a bug or not rockycho912 Excel Worksheet Functions 3 September 6th 08 06:37 AM
hlookup problem Desperate Excel Discussion (Misc queries) 3 August 14th 08 07:24 PM
hlookup problem Desperate Excel Discussion (Misc queries) 1 August 8th 08 05:21 AM
HLookup problem with dates searcherlady Excel Discussion (Misc queries) 7 June 8th 07 08:06 PM


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