need help simplying my formula..

M

Mo2

for cell D25:
=IF(A25=0,0,IF(RIGHT(B25,4)="Road","Road",IF(RIGHT(B25,6)="Bridge","Road",IF(RIGHT(B25,7)="Highway","Road"))))

this means that, B25 could be "Bay bridge", "County Road", "Blue Highway",
etc etc
and the result for D25 would be "Road"

is there a simpler way of writing this formula?

2nd question:
for cell B5
IF(A1=0,0,IF(C2=4,IF(A1=5,5,IF(A1=6,6),A1)))

can i write this any simpler?

tia
 
T

Trevor Shuttleworth

One way for the first part:

=IF(A25=0,0,IF(OR(RIGHT(B25,4)="Road",RIGHT(B25,6)="Bridge",RIGHT(B25,7)="Highway"),"Road",""))

Can't get my head round what you're trying to do in the second question

Regards

Trevor
 
J

JMB

Another option for your first question
=IF(A25,IF(SUMPRODUCT(--(RIGHT(B25,{4,6,7})={"Road","Bridge","Highway"})),"Road",""),)


For your second question perhaps:
=A1*(C2=4)
 
M

Mo2

sry, i messed up on the 2nd q...
i meant this:
this is for E23:

=IF(D23=0,
T: 0,
F: IF(D24=0,
T: 0,
F: IF(B24="Road",
T: IF(B23="Road",
T: 1,
F: D24),
F: IF(L24=4,
T: IF(D24=5,
T: 5,
F: IF(D24=6,
T: 6,
F: 4)),
F: IF(D23=6,
T: 5,
F: D24)))))

i hope that makes sense..
(this is excluding the stuff from question1)

at some point in that formula it says:
if (cell) = 6 ,
TRUE: 6
FALSE: if (cell) = 5,
TRUE: 5
FALSE: (something else)

can i write something like...
if <cell> = (6,5) , (6,5)

or.. i donno
 
J

JMB

This appears to do what you are asking.

=IF(D23*D24,IF(B24="Road",IF(B23="Road",1,D24),IF(L24=4,MAX(L24,OR(D24={5,6})*D24),MAX((D23=6)*5,(D23<>6)*D24))),)
 
J

JMB

slightly shorter

=IF(D23*D24,IF(B24="Road",IF(B23="Road",1,D24),IF(L24=4,MAX(L24,OR(D24={5,6})*D24),IF(D23=6,5,D24))),)
 
M

Mo2

Sorry, your formula didnt help..
let me start over, (and also change a few things , my bad)
and it must check the conditions in this order:

if D23 is a 0,
then activecell (e23) should be a 0, regardless of D24's
value.
if D24 is a 0,
then activecell (e23) should be a 0, regardless of whatever.
if D23 is a 6, then CHECK IF d24 is also a 6 (if true, e23= 6. if false,
e23= 5).
if B24 says ("*Road" / "*Bridge" / "*Highway" <-- the * is a wildcard)
then CHECK IF B23 is also a "*Road" or a "*Bridge" or a
"*Highway"
(it doesnt have to be the same as b24's word)
if true, activecell (e23) should be 1
if b24 is one of those words, but b23 is not, copy
D24's value.
(if neither is the case, check the next condition)

if L24 is 4, check if D24 is a 5 (if its true, make activecell a 5, if not,
check if D24 is a 6 (if true, make activecell a 6) , else
make it a 4.

if D23 is any other number, activecell(E23) should copy D24's value.
(welll, preferrably, i wouldnt want D23 or D24 to be less than 0 or higher
than 6, or have text in it, but that will just make the formula that much
more complicated. I'm pretty sure whoever uses my sheet will remember to keep
the D column's values within that range..)'

btw, one reason your formula didnt work is becuz you're combining numbers..
multiplying D23 and D24 , if i understand correctly.
maybe i shouldve mentioned that the numbers are actually variables (for
something else, outside of excel)
so combining numbers would screw everything up for me

do you think u can give this another wack pls?
or is my formula is as simple as it can get, for what i'm trying to ask?
(minus the newly learned wildcard thing)
if its not, could u possibly include the wildcard thing in your formula?

thanks



sry, that doesnt work..
your formula requires that d23 must be a 1, in order for the active cell to
result in D24's value.
if D23 is anything other than 1, the active cell doesnt change (remains a "0")

that isn't correct. (and srry, i'm gonna change up something else here)

The formula should allow D23 to be any value (except 0 or 6)
in order for the active cell (E23) to copy D24's value.

if D23 is a 0, activecell (e23) should be a 0, regardless of D24's value.
if D23 is a 6, activecell (e23) should CHECK IF d24 is also a 6 (if true, =
6. if false, = 5).
 
J

JMB

Having trouble following. I would suggest taking a closer look at your
spreadsheet design and perhaps breaking things down into smaller steps
instead of trying to put everything into one formula. I think a formula
w/this many conditions will be difficult to maintain.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top