|
-
January 13th, 2010, 02:43 PM
#1
VB 6 If Statement question
=IF(LEFT(RC[2],1)=""0"",IF(mid(RC[2],10,2)=""-c"",LEFT(RC[2],11),LEFT(RC[2],9)),if(right(rc[2],2)=""-c"",RIGHT(RC[2],11),RIGHT(RC[2],9)))"
With the code above:
=IF(LEFT(RC[2],1)=""0"", - looks for zero(0) as the first character in the cell. I want to search for one(1) also.
If I change the "0" to "1" I get all that begin with 1. I need to find both "0" and "1"
Data I'm looking for:
09-B-6399
10-B-0568
Hopefully you can help, need this for work, creator has moved onto another company.
Dave
-
January 13th, 2010, 04:58 PM
#2
Re: VB 6 If Statement question
Hello, dintym
Wrong section ...
It's anything (VBA/Excel, I guess) but VB6 !
Sorry : it's not even VBA, but an Excel Formula in an Excel cell...
-
January 13th, 2010, 08:12 PM
#3
Re: VB 6 If Statement question
-
January 14th, 2010, 03:27 AM
#4
Re: VB 6 If Statement question
It's not VB (as said) but an Excel Formula.
The logic of the syntax is then quite different from VB and should respond to this mecanism :
= IF(OR(expression1,expression2)......)
where :
expression1 has to express that the first character is a "0"
expression2 has to express thant the firts character is a "1"
An example (but on my French Excel Version, so that it has to be transformed...)
Code:
= SI(OU(GAUCHE(B2;1) = "0";GAUCHE(B2;1) ="1");VRAI;FAUX)
this, placed in the cell C4 (for instance) would display (in C4) a boolean showing whether the first character in B2 is or not a "0" or a "1" .
The transposition for an english version should be (I think) something like this :
Code:
= IF(OR(LEFT(B2,1) = "0",LEFT(B2,1) ="1"),TRUE,FALSE)
Just observe : the transposition is not only a translation of the words. Notice than every : (in french formula) is now a , (in english formula). Well (from what I guess....)
Well... This is exactly why the present discussion should not be opened in VB6 section. 
EDIT : a big mistake would be to use a single comparison with < "2", as (for instance) "^blabla" would display TRUE !
EDIT 2
One could also use the AND function, like this :
Code:
= IF(AND(LEFT(B2,1) >= "0",LEFT(B2,1) <"2"),TRUE,FALSE)
Last edited by moa; January 14th, 2010 at 04:00 AM.
-
January 14th, 2010, 07:56 PM
#5
Re: VB 6 If Statement question
or like this (from ENGLISH version of Excel 2007)
B3 is text
Code:
=IF(OR(LEFT(B3,2)="00",LEFT(B3,2)="01"),TRUE,FALSE)
-
January 15th, 2010, 02:35 AM
#6
Re: VB 6 If Statement question
Let us now hope that dintym, who seems to be a beginner, will understand that the project he is working on is using the R1C1 notation, so that the absolute address (ie B2 or B3 in our examples) has to be replaced by RC[2] in his project.
We never know
-
January 17th, 2010, 09:44 PM
#7
Re: VB 6 If Statement question
I stand corrected and humbled. Thanks for being kind to one who is better at repairing cars and raising chickens than programming.
Dave Dinty Moore
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|