Compile Error Expected End Of Statement Visual Basic
Contents |
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev visual basic compile error expected = centers Retired content Samples We’re sorry. The content you requested has been removed. compile error expected end of statement macro You’ll be auto redirected in 1 second. Visual Basic Reference Visual Basic Language Reference Error Messages Error Messages End compile error expected end of statement vba of statement expected End of statement expected End of statement expected '#ElseIf' must be preceded by a matching '#If' or '#ElseIf' '#Region' and '#End Region' statements are not valid within method vbscript compilation error expected end of statement bodies/multiline lambdas '
Microsoft Vbscript Compilation Error Expected End Of Statement
implemented by the base class '
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
Visual Basic Compile Error User Defined Type Not Defined
this site About Us Learn more about Stack Overflow the company Business visual basic compile error sub or function not defined Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask visual basic compile error object library invalid 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 https://msdn.microsoft.com/en-us/library/8dy0ah20.aspx 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 YES and NO and run the macro, it will http://stackoverflow.com/questions/24173238/expected-end-of-statement-in-formula-with-quotes 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 accepted Double-quotes in strings need to be escaped by doubling them up: Range("D2:D56").SpecialCells(xlCellTypeBlanks).Formula = _ "=IF(AND(C>800,C<900), ""YES"", ""NO"")" share|improve
this is your first visit, be sure to check out the FAQ by clicking the http://www.vbforums.com/showthread.php?521514-RESOLVED-Expected-end-of-statement link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that http://www.techrepublic.com/forums/discussions/microsoft-visual-basic-error-expected-end-of-statement/ you want to visit from the selection below. Results 1 to 6 of 6 Thread: [RESOLVED] Expected end of statement Tweet Thread Tools Show Printable compile error Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode May 5th, 2008,12:21 PM #1 Mikey View Profile View Forum Posts Thread Starter Hyperactive Member Join Date Jan 2001 Posts 430 [RESOLVED] Expected end of statement I don't get it... [1025] Microsoft VBScript compilation error: Expected error expected end end of statement at line:7, char:12 near: Dim objConn As ADODB.Connection Code: function main s = RegExpTest("(\d{1,2}\/\d{1,2}\/\d{4,4})\s+(\d{1,2}:\d{1,2}:\d{1,2}\s(AM|PM)),([-+]?\d+(\.\d+)?),([-+]?\d+(\.\d+)?),([-+]?\d+(\.\d+)?),([-+]?\d+(\.\d+)?),([-+]?\d+(\.\d+)?),([-+]?\d+(\.\d+)?)",Body.Value) end function Function RegExpTest(patrn, strng) Dim edate, etime, ctemp, ftemp, field5, field6, field7, field8 Dim regExp, Match, Matches, submatch, strQuery Dim objConn As ADODB.Connection Dim objRS As ADODB.Recordset Dim strConn As String Dim strConnection As String Set objRS = New ADODB.Recordset Set objConn = CreateObject("ADODB.Connection") Set regEx = New RegExp regEx.Pattern = patrn regEx.IgnoreCase = True regEx.Global = True Set Matches = regEx.Execute(strng) strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" strConnection = strConnection & "Data Source=d:\database\test.mdb;" strConnection = strConnection & "Persist Security Info=False" objConn.Open strConnection For Each Match in Matches edate = match.submatches(0) etime = match.submatches(1) ctemp = match.submatches(3) ftemp = match.submatches(5) field5 = match.submatches(7) field6 = match.submatches(9) field7 = match.submatches(11) field8 = match.submatches(13) strQuery = "SELECT * FROM TESTTBL WHERE Field1 = #" & edate & "# AND Field2 = #" & etime & "#" objRS.Open strQuery, str
United States Australia United Kingdom Japan Newsletters Forums Resource Library Tech Pro Free Trial Membership Membership My Profile People Subscriptions My stuff Preferences Send a message Log Out TechRepublic Search GO Topics: CXO Cloud Big Data Security Innovation Software Data Centers Networking Startups Tech & Work All Topics Sections: Photos Videos All Writers Newsletters Forums Resource Library Tech Pro Free Trial Editions: US United States Australia United Kingdom Japan Membership Membership My Profile People Subscriptions My stuff Preferences Send a message Log Out TechRepublic | Forums | Software Software Register Now or Log In to post Welcome back, My Profile Log Out Recent Activity FAQs Guidelines Question 0 Votes Locked Microsoft Visual Basic error: "expected: end of statement" By Mobil-D · 7 years ago I'm experiencing an issue with macros in Word 2007. I copied the following code verbatim from MSDN (URL at bottom) into Microsoft Visual Basic: -Public Function GetScreenTip(ByVal control As IRibbonControl) As String Return "This is a screen tip for the menu."End FunctionHowever, I get a compiler error, "expected: end of statement", referring to the return statement. Now I'm no expert programmer, but from what I understand, it's pretty well commonplace for a function to return a value. I don't have much of a clue when it comes to VB though. Could anyone help me out?http://msdn.microsoft.com/en-us/library/bb462634.aspx Share Flag This conversation is currently closed to new comments. 5 total posts (Page 1 of 1) + Follow this Discussion · | Thread display: Collapse - | Expand + All Answers Collapse - No such thing as "return" by Slayer_ · 7 years ago In reply to Microsoft Visual Basic er ... Public Function GetScreenTip(ByVal control As IRibbonControl) As StringGetScreenTip = "This is a screen tip for the menu."End FunctionTry that 0Votes Share Flag Collapse - Another error by Mobil-D · 7 years ago In reply to No such thing as "return" Thanks for that, but now I get another error when I call the function, "Wrong number of arguments or invalid property assignment". Any ideas? 0Votes Share Flag Collapse - Resolved by Mobil-D · 7 years ago In reply to Another error Just to say that I've resolved this issue, like so: -Sub GetScreenTipcallback(control As IRibbonControl, ByRef screentip)End SubThanks again. :) 0Votes Share Flag Collapse - Bad code.... by Slayer_ · 7 years ago In re