Compile Error Expected End Of Statement Vba
Contents |
be down. Please try the request again. Your cache administrator is webmaster. Generated Thu, 06 Oct 2016 00:32:53 GMT by s_hv1000 (squid/3.5.20)
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings
Compile Error Expected End Of Statement Visual Basic
and policies of this site About Us Learn more about Stack
Expected End Of Statement Vba Access
Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs line terminator vba Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; http://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_other/vba-compile-error-expected-end-of-statement/9b73a7cd-4476-4e19-b758-d9e0b53be097 it only takes a minute: Sign up Expected End of Statement in formula with quotes up vote 2 down vote favorite Sub FillNames() Range("D2:D56").SpecialCells(xlCellTypeBlanks).Formula = _ "=IF(AND(C>800,C<900), "YES", "NO")" End Sub I get the compile error expected: end of statement. It seems to have issue with the quotes around the words YES and NO. If I remove the quotes around http://stackoverflow.com/questions/24173238/expected-end-of-statement-in-formula-with-quotes YES and NO and run the macro, it will run and print what is in the formula quotes into the cell. I don't understand then how the quotes cause a syntax error. I am running Excel 2011 for Mac, don't know if that has anything to do with it. excel vba excel-2011 share|improve this question edited Mar 22 '15 at 1:37 ZygD 3,03991933 asked Jun 11 '14 at 21:54 PA_Commons 37129 Add Option Explicit to the top of the module and let us know what happens. –Smandoli Jun 11 '14 at 21:56 all it did was separate the code into it's own code window –PA_Commons Jun 11 '14 at 21:59 Sub FillNames() Range("D2:D56").SpecialCells(xlCellTypeBlanks).Formula = "=IF(AND(C>800,C<900), YES, NO)" End Sub –PA_Commons Jun 11 '14 at 22:00 that will print what is between the "" after the = into the cells, it won't function obviously, because it's not properly formatted. –PA_Commons Jun 11 '14 at 22:00 add a comment| 1 Answer 1 active oldest votes up vote 4 down vote acc
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring http://stackoverflow.com/questions/27760849/vba-compile-error-expected-end-of-statement developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up VBA Compile error: Expected end of statement up vote 0 down vote favorite I am trying to code a combo box in a form such that it automatically filters the options as compile error the user types. I have a code but I keep getting a compile error. Here is my code: Private Sub UTIL_FCLTY_ID_Change() If Nz(Me.UTIL_FCLTY_ID.Text) = “” Then Me.Form.Filter = “” Me.FilterOn = False ElseIf Me.UTIL_FCLTY_ID.ListIndex <> -1 Then Me.Form.Filter = “[UTILITY FACILITY TYPE NAME:] = ‘” & _ Replace(Me.UTIL_FCLTY_ID.Text, “‘”, “””) & “‘” Me.FilterOn = True Else Me.Form.Filter = “[UTILITY FACILITY TYPE NAME:] Like ‘*” & _ Replace(Me.UTIL_FCLTY_ID.Text, “‘”, “””) & “*'” Me.FilterOn = True End If Me.UTIL_FCLTY_ID.SetFocus Me.UTIL_FCLTY_ID.SelStart = compile error expected Len(Me.UTIL_FCLTY_ID.Text) End Sub vba ms-access access-vba share|improve this question edited Jan 3 '15 at 23:54 HansUp 79.1k114371 asked Jan 3 '15 at 23:49 user4403907 11 2 That code sample has typesetting quotes (“”) instead of plain quotes (""). If your real code also includes typesetting quotes, you should change them to plain quotes. –HansUp Jan 3 '15 at 23:53 Which line of the code triggers the compile error? Is it the line which ends with & “*'”? That looks like a quote problem ... notice how it affects the syntax coloring at that point. –HansUp Jan 3 '15 at 23:54 There are two specific errors now. 1. In the Else if the error is Expected: list separator or ) --> This one highlights the "'" at the end of the statement. 2. In the Else if the error is Expected: expression --> This one highlights the apostrophe in "*'" –user4403907 Jan 4 '15 at 0:04 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote As @HansUp mentioned, you use non-standard quotes and non-standard apostrophe. Replace them with correct one. Second issue is with this statement: """. VBA compiler sees it as "" " (empty string and unclosed quote). You need to use double quote inside quote to workaround it: """"" Finally your procedure should look like: Private Sub UTIL_FCLTY_ID_Change() If Nz(Me.UTIL_FCLTY_ID.Text) = "" Then M