Compile error - expected end of statement

2022

Board Regular
Joined
Jun 5, 2022
Messages
74
Office Version
  1. 2016
Platform
  1. Windows
Does anyone know why this formula would give a compile error (expected end of statement ) after the first space underscore " _" (third line below)?

VBA Code:
"=IF(A32="""","""",IF(AND($N$26<>""CAD"",BR32=""TRUE""),ROUND(VLOOKUP(UPPER(CONCAT($BW$34,""_"",'Contract pg 1'!A32)),data_fin,8,0),2)/$B$4,IF(AND($N$15=""X11"",$AL$13=""ABC1"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,4,FALSE)/$B$4, _

IF(AND($N$15=""X11"",$AL$13=""ABC2"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,6,FALSE)/$B$4,IF(AND($N$15=""X11"",$AL$13=""ABC3"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,8,FALSE)/$B$4,IF(AND($AK$14=""X11"",$AL$13=""ABC1"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,4,FALSE)/$B$4, _

IF(AND($AK$14=""X11"",$AL$13=""ABC2"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,6,FALSE)/$B$4,IF(AND($AK$14=""X11"",$AL$13=""ABC3"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,8,FALSE)/$B$4,IF(AND($AK$14=""X22"",$AL$13=""ABC1"",CB32=""TRUE""),VLOOKUP(UPPER(A32),XORange,5,FALSE)/$B$4, _

IF(AND($AK$14=""X22"",$AL$13=""ABC2"",CB32=""TRUE""),VLOOKUP(UPPER(A32),XORange,7,FALSE)/$B$4,IF(AND($AK$14=""X22"",$AL$13=""ABC3"",CB32=""TRUE""),VLOOKUP(UPPER(A32),XORange,9,FALSE)/$B$4,IF(BP32=""TRUE"",VLOOKUP(UPPER(A32),NewList,2,FALSE)/$B$4, _

IF(BT32=""TRUE"",ROUND(VLOOKUP(UPPER(A32),data_list,3,0),2)/$B$4,"""")))))))))))))"
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
You can't put the underscore inside the formula string. You need to terminate that line with a quote, ampersand and underscore, then start the next line with a quote:

VBA Code:
"=IF(A32="""","""",IF(AND($N$26<>""CAD"",BR32=""TRUE""),ROUND(VLOOKUP(UPPER(CONCAT($BW$34,""_"",'Contract pg 1'!A32)),data_fin,8,0),2)/$B$4,IF(AND($N$15=""X11"",$AL$13=""ABC1"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,4,FALSE)/$B$4," & _
"IF(AND($N$15=""X11"",$AL$13=""ABC2"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,6,FALSE)/$B$4,IF(AND($N$15=""X11"",$AL$13=""ABC3"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,8,FALSE)/$B$4,IF(AND($AK$14=""X11"",$AL$13=""ABC1"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,4,FALSE)/$B$4," &  _
"IF(AND($AK$14=""X11"",$AL$13=""ABC2"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,6,FALSE)/$B$4,IF(AND($AK$14=""X11"",$AL$13=""ABC3"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,8,FALSE)/$B$4,IF(AND($AK$14=""X22"",$AL$13=""ABC1"",CB32=""TRUE""),VLOOKUP(UPPER(A32),XORange,5,FALSE)/$B$4," &  _
"IF(AND($AK$14=""X22"",$AL$13=""ABC2"",CB32=""TRUE""),VLOOKUP(UPPER(A32),XORange,7,FALSE)/$B$4,IF(AND($AK$14=""X22"",$AL$13=""ABC3"",CB32=""TRUE""),VLOOKUP(UPPER(A32),XORange,9,FALSE)/$B$4,IF(BP32=""TRUE"",VLOOKUP(UPPER(A32),NewList,2,FALSE)/$B$4," &  _
"IF(BT32=""TRUE"",ROUND(VLOOKUP(UPPER(A32),data_list,3,0),2)/$B$4,"""")))))))))))))"
 
Upvote 1
Solution
You can't put the underscore inside the formula string. You need to terminate that line with a quote, ampersand and underscore, then start the next line with a quote:

VBA Code:
"=IF(A32="""","""",IF(AND($N$26<>""CAD"",BR32=""TRUE""),ROUND(VLOOKUP(UPPER(CONCAT($BW$34,""_"",'Contract pg 1'!A32)),data_fin,8,0),2)/$B$4,IF(AND($N$15=""X11"",$AL$13=""ABC1"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,4,FALSE)/$B$4," & _
"IF(AND($N$15=""X11"",$AL$13=""ABC2"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,6,FALSE)/$B$4,IF(AND($N$15=""X11"",$AL$13=""ABC3"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,8,FALSE)/$B$4,IF(AND($AK$14=""X11"",$AL$13=""ABC1"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,4,FALSE)/$B$4," &  _
"IF(AND($AK$14=""X11"",$AL$13=""ABC2"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,6,FALSE)/$B$4,IF(AND($AK$14=""X11"",$AL$13=""ABC3"",BZ32=""TRUE""),VLOOKUP(UPPER(A32),XORange,8,FALSE)/$B$4,IF(AND($AK$14=""X22"",$AL$13=""ABC1"",CB32=""TRUE""),VLOOKUP(UPPER(A32),XORange,5,FALSE)/$B$4," &  _
"IF(AND($AK$14=""X22"",$AL$13=""ABC2"",CB32=""TRUE""),VLOOKUP(UPPER(A32),XORange,7,FALSE)/$B$4,IF(AND($AK$14=""X22"",$AL$13=""ABC3"",CB32=""TRUE""),VLOOKUP(UPPER(A32),XORange,9,FALSE)/$B$4,IF(BP32=""TRUE"",VLOOKUP(UPPER(A32),NewList,2,FALSE)/$B$4," &  _
"IF(BT32=""TRUE"",ROUND(VLOOKUP(UPPER(A32),data_list,3,0),2)/$B$4,"""")))))))))))))"
That worked! Thank you!
 
Upvote 0

Forum statistics

Threads
1,215,268
Messages
6,123,970
Members
449,137
Latest member
yeti1016

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top