View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Glenn Glenn is offline
external usenet poster
 
Posts: 1,240
Default IF Statement Modifications

The statement (FIND(B7,"HKMP")-1) will return a number from 0 to 3 depending
upon the contents of B7. That result times 3 plus 1 (*3+1) turns {0, 1, 2, 3}
into {1, 4, 7, 10}. So, assuming B7 contains "M", you would get 7. The rest is
straight forward:

MID("JERSHJMCJNOP",7,3)="MCJ"


Workbook wrote:
Thanks Glen, this is really cool. It works great.

Is this part of the code ")-1)*3+1,3)) saying something to the effect of
(excuse my VBA translation), count 3 letters there and stick 3 letters here,
count 1 letter here and stick one letter there? Does my question make sense?




"Glenn" wrote:

Workbook wrote:
Thank you TValko for this statement =IF(Sheet1!B7="H","JER",""). I am
wondering can it be modified to include the 4 following variations so that if
H, K, M, or P is entered into cell B7 the associated acronym will appear?

If K is entered in cell B7 on Sheet1 then SHJ will appear in J7
If M is entered in cell B7 on Sheet1 then MCJ will appear in J7
If P is entered in cell B7 on Sheet1 then NOP will appear in J7


One way:

=IF(ISERROR(FIND(B7,"HKMP")),"",MID("JERSHJMCJNOP" ,(FIND(B7,"HKMP")-1)*3+1,3))