Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Code to Ignore Certain Cases in a Looping Function

I had a VBA expert create a program for me, and it has worked perfectly for
months. However, recently I found there was an error because at a certain
point the program excludes certain inputs that meet a certain criteria. The
exact code is:
If Left$(Instrument$, 3) < "SPX" Then
The problem is there is one scenario where the instrument starts with "SPX"
but I don't want to exclude it. There are twelve different strings that
might start with SPX, is there anyway to specify the first four letters, and
exclude SPXJ, SPXK, SPXG, SPXH, etc? I tried listing all these scenarios
where "SPX" currently is and putting "or" between them, but I keep getting
errors. ANy ideas?

Thanks

Adam Bush
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Code to Ignore Certain Cases in a Looping Function

You don't say which 4th letter you want to keep so I am putting in Z

If Left$(Instrument$, 3) < "SPX" or left$(Instrument$,4) = "SPXZ" Then

Peter Richardson

" wrote:

I had a VBA expert create a program for me, and it has worked perfectly for
months. However, recently I found there was an error because at a certain
point the program excludes certain inputs that meet a certain criteria. The
exact code is:
If Left$(Instrument$, 3) < "SPX" Then
The problem is there is one scenario where the instrument starts with "SPX"
but I don't want to exclude it. There are twelve different strings that
might start with SPX, is there anyway to specify the first four letters, and
exclude SPXJ, SPXK, SPXG, SPXH, etc? I tried listing all these scenarios
where "SPX" currently is and putting "or" between them, but I keep getting
errors. ANy ideas?

Thanks

Adam Bush

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Code to Ignore Certain Cases in a Looping Function

Peter,

Thank you very much for your help. I thought for some reason I had to list
the strings to exclude, not to include.

Thanks Again,

Adam Bush

"barnabel" wrote:

You don't say which 4th letter you want to keep so I am putting in Z

If Left$(Instrument$, 3) < "SPX" or left$(Instrument$,4) = "SPXZ" Then

Peter Richardson

" wrote:

I had a VBA expert create a program for me, and it has worked perfectly for
months. However, recently I found there was an error because at a certain
point the program excludes certain inputs that meet a certain criteria. The
exact code is:
If Left$(Instrument$, 3) < "SPX" Then
The problem is there is one scenario where the instrument starts with "SPX"
but I don't want to exclude it. There are twelve different strings that
might start with SPX, is there anyway to specify the first four letters, and
exclude SPXJ, SPXK, SPXG, SPXH, etc? I tried listing all these scenarios
where "SPX" currently is and putting "or" between them, but I keep getting
errors. ANy ideas?

Thanks

Adam Bush

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default Code to Ignore Certain Cases in a Looping Function

If I am not mistaken, your suggested If-Then statement can be replaced by
this one...

If Not Instrument$ Like "SPX[!Z]*" Then

Rick


"barnabel" wrote in message
...
You don't say which 4th letter you want to keep so I am putting in Z

If Left$(Instrument$, 3) < "SPX" or left$(Instrument$,4) = "SPXZ" Then

Peter Richardson

" wrote:

I had a VBA expert create a program for me, and it has worked perfectly
for
months. However, recently I found there was an error because at a
certain
point the program excludes certain inputs that meet a certain criteria.
The
exact code is:
If Left$(Instrument$, 3) < "SPX" Then
The problem is there is one scenario where the instrument starts with
"SPX"
but I don't want to exclude it. There are twelve different strings that
might start with SPX, is there anyway to specify the first four letters,
and
exclude SPXJ, SPXK, SPXG, SPXH, etc? I tried listing all these scenarios
where "SPX" currently is and putting "or" between them, but I keep
getting
errors. ANy ideas?

Thanks

Adam Bush


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Code to Ignore Certain Cases in a Looping Function

Quite true but I don't want to have to teach and debug somebody else's
regular expressions if they don't know what they are.

"Rick Rothstein (MVP - VB)" wrote:

If I am not mistaken, your suggested If-Then statement can be replaced by
this one...

If Not Instrument$ Like "SPX[!Z]*" Then

Rick


"barnabel" wrote in message
...
You don't say which 4th letter you want to keep so I am putting in Z

If Left$(Instrument$, 3) < "SPX" or left$(Instrument$,4) = "SPXZ" Then

Peter Richardson

" wrote:

I had a VBA expert create a program for me, and it has worked perfectly
for
months. However, recently I found there was an error because at a
certain
point the program excludes certain inputs that meet a certain criteria.
The
exact code is:
If Left$(Instrument$, 3) < "SPX" Then
The problem is there is one scenario where the instrument starts with
"SPX"
but I don't want to exclude it. There are twelve different strings that
might start with SPX, is there anyway to specify the first four letters,
and
exclude SPXJ, SPXK, SPXG, SPXH, etc? I tried listing all these scenarios
where "SPX" currently is and putting "or" between them, but I keep
getting
errors. ANy ideas?

Thanks

Adam Bush





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
Formula for Cases=144 * # of Cases + Pieces Inventory Formula Excel Discussion (Misc queries) 2 December 29th 09 09:09 PM
Calling macros, looping function? Can this code be written more efficiently? Punsterr Excel Programming 4 October 7th 05 07:16 PM
Change looping process to ignore certain sheets Rob Excel Programming 6 May 16th 05 07:03 PM
GCD Function doesn't work in some cases GCD_Dilemma Excel Worksheet Functions 5 November 8th 04 08:18 PM
Code looping when it should not Todd Huttenstine Excel Programming 3 May 13th 04 09:37 PM


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