Ignoring cells using IF

H

Hamed parhizkar

I have a really long formula that works perfectly except for one thing. Here
is the formula below, it looks complicated but its just the same couple
formulas over and over for different cells. One thing I am trying to do is if
b8= "" or 0, then I want the output to ignore A8 otherwise let the formula
continue. So basically if there is nothing in B8 then I dont want the output
to spit out the contents in A8.

=IF(A8<>0,A8&"\r","")&IF(B8<>0,B8*100&"\r","")&IF(A8=11302,$G$1&"\r","")&IF(A8=1302,$G$1&"\r","")&IF(C8<>0,C8&"\r","")&IF(J8="Y",J8&"\r","")&IF(J8="N",J8&"\r","")&IF(A8<>0,IF(D8<>0,D8&"\r",""),"")&IF(F8<>0,F8&"\r","")&IF(G8<>0,G8*-100&"\r","")&IF(F8=11302,$G$1&"\r","")&IF(F8=1302,$G$1&"\r","")&IF(H8<>0,H8&"\r","")&IF(K8="Y",K8&"\r","")&IF(K8="N",K8&"\r","")&IF(F8<>0,IF(D8<>0,D8&"\r",""),"")
 
R

RyanH

Wow, that is pretty confusing. I'm not sure if this will help, but I would
suggest making your own Custom Function in VBA. You could start it like this:

Public Function myFunction(cell1 As Range, cell2 As Range, cell3 As Range,
cell4 As Range)

'cell1 could be A8
'cell2 could be B8
'cell3 could be C8
'etc

If IsEmpty(cell2) = False Then

If cell1 <> 0 Then
cell1 = cell1 & "\r"
Else
cell1 = ""
End If

If cell2 <> 0 Then
cell2 = cell2 * 100 & "\r"
Else
cell2 = ""
Else

'the rest of your code using if then statements

Else
cell1 = ""
End If

End Function

In whatever cell you want the result in just type this. arg1, arg2, arg3,
arg4 are cells you want to use in the function I typed above.

=myFunction(arg1,arg2,arg3,arg4)

I hope this helps!
 

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