Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formula for Cases=144 * # of Cases + Pieces | Excel Discussion (Misc queries) | |||
Calling macros, looping function? Can this code be written more efficiently? | Excel Programming | |||
Change looping process to ignore certain sheets | Excel Programming | |||
GCD Function doesn't work in some cases | Excel Worksheet Functions | |||
Code looping when it should not | Excel Programming |