Expected End of Statement and Syntax for User Defined Function

SBF12345

Well-known Member
Joined
Jul 26, 2014
Messages
614
Greetings,

I am currently receiving a Expected End of Statement Error on the following line.

Code:
wkbk_LO.Worksheets(c).Range(Cells(g, "A")).value = "=INDEX(PERSONAL.XLS!LOGIT([LOGREG_INPUT.xls].worksheets(c).Range(cells(2,"B"),cells(g,"B")), [LOGREG_INPUTS.xls].worksheets(c).Range(cells(2,"D"),cells(h,"I")),0.8,TRUE,TRUE),ROW(A1),COLUMN(A1))"

The user defined function includes the following variables:

Code:
Function Logit(known_y As Range, known_x As Range, Cutoff As Double, Optional Constant As Boolean = True, Optional Stats = False)

and outputs an "output" array:

Code:
ReDim output(1 To 26, 1 To M + 1) As Variant

My question is how the user defined function should appear in a vba subroutine to produce output of the size shown above. I suspect that the INDEX statement will need to show a range of cells instead of ROW(A1), COLUMN(A1).

Thanks
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Without trying to decipher your function to see if there are any other problems, I do note that you need to double up your internal quote marks within the quote marks delimiting your text constant...
Code:
[table="width: 500"]
[tr]
	[td]wkbk_LO.Worksheets(c).Range(Cells(g, "A")).value = "=INDEX(PERSONAL.XLS!LOGIT([LOGREG_INPUT.xls].worksheets(c).Range(cells(2,"[B][COLOR="#FF0000"]"[/COLOR][/B]B[B][COLOR="#FF0000"]"[/COLOR][/B]"),cells(g,"[B][COLOR="#FF0000"]"[/COLOR][/B]B[B][COLOR="#FF0000"]"[/COLOR][/B]")), [LOGREG_INPUTS.xls].worksheets(c).Range(cells(2,"[B][COLOR="#FF0000"]"[/COLOR][/B]D[B][COLOR="#FF0000"]"[/COLOR][/B]"),cells(h,"[B][COLOR="#FF0000"]"[/COLOR][/B]I[B][COLOR="#FF0000"]"[/COLOR][/B]")),0.8,TRUE,TRUE),ROW(A1),COLUMN(A1))"[/td]
[/tr]
[/table]
 
Last edited:
Upvote 0
Thanks, I am unfamiliar with the rules surrounding the use of double quotation marks. I would not have guessed they were required in this case!

As for the function, it seems to be running smoothly.
 
Upvote 0
Thanks, I am unfamiliar with the rules surrounding the use of double quotation marks.
When you have a text constant (a bunch of characters with a quote mark on each end), you must double up each internal quote mark... this tell VB that the quote mark is a character in the text... if you only put a single internal quote mark, VB thinks that is the end of the text constant and then gets confused at all the characters that follow it.
 
Upvote 0
Thank you, I'll remember there are special rules surrounding text constants next time they find their way into a script.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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