VBA formula too large

I think that I have a formula too large for VBA, I can't find any errors, but it is red.
Seems that I may need another solution, if there a way to split up and concatenate maybe?

Sub Calc()
Dim lngLastRowD As Long


With Sheets("Detail")
lngLastRowD = Sheets("Detail").Range("BI80000").End(xlUp).Row
.Range("BJ2:BJ" & lngLastRowD).Formula = "=IF(OR($F2={""FO"",""PO"",""SO"",""E2AM"",""E2"",""ESP""}),VLOOKUP($BG2,'Dom Ex'!$A$3:$AP$2000,40,FALSE), _
IF(OR($F2={""GR"",""HD"",""PRP""}),VLOOKUP($BG2,Ground!$A$3:$AP$2000,40,FALSE),IF(OR($F2={""F1"",""F2"",""F3""}), _
VLOOKUP(151,INDIRECT(""DOM_""&$F2&""_MIN""),Detail!$BD2,FALSE),IF(AND($F2=""IP"",$BB2=""Letter"",$AT2=""PR"",$AV2=""EXPORT""),_
VLOOKUP(1,IP_EX_PR_L,2,FALSE),IF(AND($F2=""IP"",$BB2=""Box"",$AT2=""PR"",$AV2=""EXPORT""), _
VLOOKUP(1,IP_EX_PR,2,FALSE),IF(AND($F2=""IE"",$AT2=""PR"",$AV2=""EXPORT""),VLOOKUP(1,IE_EX_PR,2,FALSE), _
IF(AND($F2=""IP"",$AV2=""EXPORT"",$BB2=""Letter""),VLOOKUP(1,IP_EX_MIN,$BD2,FALSE),IF(AND($F2="IP",$AV2=""EXPORT"",$BB2=""Pak""), _
VLOOKUP(2,IP_EX_MIN,$BD2,FALSE),IF(AND($F2=""IP"",$AV2=""EXPORT"",$BB2=""Box""),VLOOKUP(3,IP_EX_MIN,$BD2,FALSE), _
IF(AND($F2=""IE"",$AV2=""EXPORT""),VLOOKUP(1,IE_EX_MIN,$BD2,FALSE),IF(AND($F2=""IP"",$AV2=""IMPORT"",$BB2=""Letter""), _
VLOOKUP(1,IP_IMP_MIN,$BD2,FALSE),IF(AND($F2=""IP"",$AV2="IMPORT",$BB2="Pak"),VLOOKUP(2,IP_IMP_MIN,$BD2,FALSE), _
IF(AND($F2=""IP"",$AV2=""IMPORT"",$BB2=""Box""),VLOOKUP(3,IP_IMP_MIN,$BD2,FALSE),IF(AND($F2=""IE"",$AV2 _
=""IMPORT""),VLOOKUP(1,IE_IMP_MIN,$BD2,FALSE),IF(AND($F2=""IPF"",$AT2=""PR"",$AV2=""EXPORT""), _
VLOOKUP(1,IP_EX_PR_FR_MIN,2,FALSE),IF(AND($F2=""IEF"", $AT2="PR",$AV2="EXPORT"),VLOOKUP(1,IE_EX_PR_FR_MIN,2,FALSE), _
IF(AND($F2=""IPF"", $AT2=""PR"",$AV2=""IMPORT""),VLOOKUP(1,IP_IMP_PR_FR_MIN,2,FALSE), IF(AND($F2=""IEF"",$AT2=""PR"",$AV2=""IMPORT""), _
VLOOKUP(1,IE_IMP_PR_FR_MIN,2,FALSE),IF(AND($F2=""IPF"",$AV2=""EXPORT""), _
VLOOKUP(151,IPF_EX_MIN,$BD2,FALSE),IF(AND($F2=""IEF"",$AV2=""EXPORT""),VLOOKUP(151,IEF_EX_MIN,$BD2,FALSE), _
IF(AND($F2="IPF",$AV2="IMPORT"),VLOOKUP(151,IPF_IMP_MIN,$BD2,FALSE),IF(AND($F2="IEF",$AV2="IMPORT"), _
VLOOKUP(151,IEF_IMP_MIN,$BD2,FALSE),""THEN""))))))))))))))))))))))"

End With


End Sub

Open in new window

Euro5Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kanti PrasadCommented:
Hi

Can you try this I just changed a few  ""
"=IF(OR($F2={""FO"",""PO"",""SO"",""E2AM"",""E2"",""ESP""}),VLOOKUP($BG2,'Dom Ex'!$A$3:$AP$2000,40,FALSE), _
IF(OR($F2={""GR"",""HD"",""PRP""}),VLOOKUP($BG2,Ground!$A$3:$AP$2000,40,FALSE),IF(OR($F2={""F1"",""F2"",""F3""}), _
VLOOKUP(151,INDIRECT(""DOM_""&$F2&""_MIN""),Detail!$BD2,FALSE),IF(AND($F2=""IP"",$BB2=""Letter"",$AT2=""PR"",$AV2=""EXPORT""),_
VLOOKUP(1,IP_EX_PR_L,2,FALSE),IF(AND($F2=""IP"",$BB2=""Box"",$AT2=""PR"",$AV2=""EXPORT""), _
VLOOKUP(1,IP_EX_PR,2,FALSE),IF(AND($F2=""IE"",$AT2=""PR"",$AV2=""EXPORT""),VLOOKUP(1,IE_EX_PR,2,FALSE), _
IF(AND($F2=""IP"",$AV2=""EXPORT"",$BB2=""Letter""),VLOOKUP(1,IP_EX_MIN,$BD2,FALSE),IF(AND($F2=""IP"",$AV2=""EXPORT"",$BB2=""Pak""), _
VLOOKUP(2,IP_EX_MIN,$BD2,FALSE),IF(AND($F2=""IP"",$AV2=""EXPORT"",$BB2=""Box""),VLOOKUP(3,IP_EX_MIN,$BD2,FALSE), _
IF(AND($F2=""IE"",$AV2=""EXPORT""),VLOOKUP(1,IE_EX_MIN,$BD2,FALSE),IF(AND($F2=""IP"",$AV2=""IMPORT"",$BB2=""Letter""), _
VLOOKUP(1,IP_IMP_MIN,$BD2,FALSE),IF(AND($F2=""IP"",$AV2=""IMPORT"",$BB2=""Pak""),VLOOKUP(2,IP_IMP_MIN,$BD2,FALSE), _
IF(AND($F2=""IP"",$AV2=""IMPORT"",$BB2=""Box""),VLOOKUP(3,IP_IMP_MIN,$BD2,FALSE),IF(AND($F2=""IE"",$AV2 _
=""IMPORT""),VLOOKUP(1,IE_IMP_MIN,$BD2,FALSE),IF(AND($F2=""IPF"",$AT2=""PR"",$AV2=""EXPORT""), _
VLOOKUP(1,IP_EX_PR_FR_MIN,2,FALSE),IF(AND($F2=""IEF"", $AT2=""PR"",$AV2="EXPORT"),VLOOKUP(1,IE_EX_PR_FR_MIN,2,FALSE), _
IF(AND($F2=""IPF"", $AT2=""PR"",$AV2=""IMPORT""),VLOOKUP(1,IP_IMP_PR_FR_MIN,2,FALSE), IF(AND($F2=""IEF"",$AT2=""PR"",$AV2=""IMPORT""), _
VLOOKUP(1,IE_IMP_PR_FR_MIN,2,FALSE),IF(AND($F2=""IPF"",$AV2=""EXPORT""), _
VLOOKUP(151,IPF_EX_MIN,$BD2,FALSE),IF(AND($F2=""IEF"",$AV2=""EXPORT""),VLOOKUP(151,IEF_EX_MIN,$BD2,FALSE), _
IF(AND($F2=""IPF"",$AV2=""IMPORT""),VLOOKUP(151,IPF_IMP_MIN,$BD2,FALSE),IF(AND($F2=""IEF"",$AV2=""IMPORT""), _
VLOOKUP(151,IEF_IMP_MIN,$BD2,FALSE),""THEN""))))))))))))))))))))))"

Open in new window

Euro5Author Commented:
@Kanti - Thanks - unfortunately still red. Not sure what else to try...
Kanti PrasadCommented:
Hi

Can you attach the file if the data is not sensitive?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Robert SchuttSoftware EngineerCommented:
The string concatenation should end on each line with: " & _
Then on the next line start with a double quote again.

This gives the following code:
.Range("BJ2:BJ" & lngLastRowD).Formula = "=IF(OR($F2={""FO"",""PO"",""SO"",""E2AM"",""E2"",""ESP""}),VLOOKUP($BG2,'Dom Ex'!$A$3:$AP$2000,40,FALSE)," & _
"IF(OR($F2={""GR"",""HD"",""PRP""}),VLOOKUP($BG2,Ground!$A$3:$AP$2000,40,FALSE),IF(OR($F2={""F1"",""F2"",""F3""}), " & _
"VLOOKUP(151,INDIRECT(""DOM_""&$F2&""_MIN""),Detail!$BD2,FALSE),IF(AND($F2=""IP"",$BB2=""Letter"",$AT2=""PR"",$AV2=""EXPORT"")," & _
"VLOOKUP(1,IP_EX_PR_L,2,FALSE),IF(AND($F2=""IP"",$BB2=""Box"",$AT2=""PR"",$AV2=""EXPORT""), " & _
"VLOOKUP(1,IP_EX_PR,2,FALSE),IF(AND($F2=""IE"",$AT2=""PR"",$AV2=""EXPORT""),VLOOKUP(1,IE_EX_PR,2,FALSE), " & _
"IF(AND($F2=""IP"",$AV2=""EXPORT"",$BB2=""Letter""),VLOOKUP(1,IP_EX_MIN,$BD2,FALSE),IF(AND($F2=""IP"",$AV2=""EXPORT"",$BB2=""Pak""), " & _
"VLOOKUP(2,IP_EX_MIN,$BD2,FALSE),IF(AND($F2=""IP"",$AV2=""EXPORT"",$BB2=""Box""),VLOOKUP(3,IP_EX_MIN,$BD2,FALSE), " & _
"IF(AND($F2=""IE"",$AV2=""EXPORT""),VLOOKUP(1,IE_EX_MIN,$BD2,FALSE),IF(AND($F2=""IP"",$AV2=""IMPORT"",$BB2=""Letter""), " & _
"VLOOKUP(1,IP_IMP_MIN,$BD2,FALSE),IF(AND($F2=""IP"",$AV2=""IMPORT"",$BB2=""Pak""),VLOOKUP(2,IP_IMP_MIN,$BD2,FALSE), " & _
"IF(AND($F2=""IP"",$AV2=""IMPORT"",$BB2=""Box""),VLOOKUP(3,IP_IMP_MIN,$BD2,FALSE),IF(AND($F2=""IE"",$AV2 " & _
"=""IMPORT""),VLOOKUP(1,IE_IMP_MIN,$BD2,FALSE),IF(AND($F2=""IPF"",$AT2=""PR"",$AV2=""EXPORT""), " & _
"VLOOKUP(1,IP_EX_PR_FR_MIN,2,FALSE),IF(AND($F2=""IEF"", $AT2=""PR"",$AV2=""EXPORT""),VLOOKUP(1,IE_EX_PR_FR_MIN,2,FALSE), " & _
"IF(AND($F2=""IPF"", $AT2=""PR"",$AV2=""IMPORT""),VLOOKUP(1,IP_IMP_PR_FR_MIN,2,FALSE), IF(AND($F2=""IEF"",$AT2=""PR"",$AV2=""IMPORT""), " & _
"VLOOKUP(1,IE_IMP_PR_FR_MIN,2,FALSE),IF(AND($F2=""IPF"",$AV2=""EXPORT""), " & _
"VLOOKUP(151,IPF_EX_MIN,$BD2,FALSE),IF(AND($F2=""IEF"",$AV2=""EXPORT""),VLOOKUP(151,IEF_EX_MIN,$BD2,FALSE), " & _
"IF(AND($F2=""IPF"",$AV2=""IMPORT""),VLOOKUP(151,IPF_IMP_MIN,$BD2,FALSE),IF(AND($F2=""IEF"",$AV2=""IMPORT""), " & _
"VLOOKUP(151,IEF_IMP_MIN,$BD2,FALSE),""THEN""))))))))))))))))))))))"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Euro5Author Commented:
AHHH!!!  I tried but forgot the " at the end of the lines! THANK YOU SO MUCH!!!! You really taught me something helpful!
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
@Robert Schutt

+1  :) :) :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.