vb question w/ if statment

N

Neuther

If Cells(55, 3).Value = 1 Then
Cells(28, 13).Value = Cells(12, 3).Value + Cells(24, 13) - 4
Cells(28, 12).Value = Cells(28, 12).Value - 4
Cells(24, 13).Value = ""
Else: Cells(28, 13).Value = Cells(12, 3).Value + Cells(24, 13) - 2
Cells(28, 12).Value = Cells(28, 12).valuse - 2
Cells(24, 13).Value = ""
End If

This is my formula and it doesn't work. I know that it's becasue m
else has too much stuff on it but i need it to do all this. is ther
any way i can fix this?
 
Y

Yannis

Try this (I think this one works...try Else without the ":" at the end)

If Cells(55, 3).Value = 1 Then
Cells(28, 13).Value = Cells(12, 3).Value + Cells(24, 13) - 4
Cells(28, 12).Value = Cells(28, 12).Value - 4
Cells(24, 13).Value = ""
Else
Cells(28, 13).Value = Cells(12, 3).Value + Cells(24, 13) - 2
Cells(28, 12).Value = Cells(28, 12).Value - 2
Cells(24, 13).Value = ""
End If
 
N

Neuther

Yea i tried that but vb puts the : in. I tried that but it didn't fi
it. Thanx anyway
 
D

duane

How about

If Cells(55, 3).Value = 1 Then goto one:
Cells(28, 13).Value = Cells(12, 3).Value + Cells(24, 13) - 2
Cells(28, 12).Value = Cells(28, 12).valuse - 2
Cells(24, 13).Value = ""
goto next:
one:
Cells(28, 13).Value = Cells(12, 3).Value + Cells(24, 13) - 4
Cells(28, 12).Value = Cells(28, 12).Value - 4
Cells(24, 13).Value = ""
next
 
N

Neuther

I can't get this to work either. I tired typeing it and i tried pastin
it. I couldn't get this to work either.

thanx anywa
 
D

duane

ok....you do know you are missing a ".value", and my goto statemen
should not have a ":"?

Joh
 
F

Frank Kabel

Hi
to be honest I wouldn't use this kind of code!. Try to avoid goto's in
most cases in specifically in this case no need for it. So the
following should work (Important: A linebreak directly after 'Else'. If
you enter something after 'Else' Excel treates only this line as the
else statement):

If Cells(55, 3).Value = 1 Then
Cells(28, 13).Value = Cells(12, 3).Value + Cells(24, 13) - 4
Cells(28, 12).Value = Cells(28, 12).Value - 4
Cells(24, 13).Value = ""
Else
Cells(28, 13).Value = Cells(12, 3).Value + Cells(24, 13) - 2
Cells(28, 12).Value = Cells(28, 12).value - 2
Cells(24, 13).Value = ""
End If
 
Top