Compile Error Expected End Of Statement
Contents |
be down. Please try the request again. Your cache administrator is webmaster. Generated Thu, 06 Oct 2016 00:30:44 GMT by s_hv999 (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 and policies of this site About Us Learn more about Stack Overflow the company Business expected end of statement vba sql Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation
Compile Error Expected List Separator Or
Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like compile error expected end sub you, helping each other. Join them; 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 http://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_other/vba-compile-error-expected-end-of-statement/9b73a7cd-4476-4e19-b758-d9e0b53be097 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 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 http://stackoverflow.com/questions/24173238/expected-end-of-statement-in-formula-with-quotes 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 answer answered Jun 11 '14 at 21:58 Tim Williams 56.7k74163 Firstly, Thank You. I'm sure that was simple for some. –PA_Commons Jun 11 '14 at 22:13 Secondly, I thought I had tried that, but apparently I didn't do it right! –PA_Commons Jun 11 '14 at 22:13 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up us
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 http://stackoverflow.com/questions/21341484/getting-a-compile-error-expected-end-of-statement-when-trying-to-return-a-ca Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join http://www.computerhope.com/forum/index.php?topic=143638.0 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 Getting a “Compile Error: Expected: compile error End of Statement” when trying to return a calculated value from a function up vote 1 down vote favorite I have coded a function that finds the first column that has an empty cell in the third row, but I cannot figure out how to return that integer. Function FindEmptyColumn() ' Find the first empty column to paste data into ThisWorkbook.Activate Worksheets("Black Cam Raw Data").Activate Dim compile error expected dCounter As Double dCounter = 1 Dim iColumn As Integer Do Until Cells(3, dCounter) = "" iColumn = dCounter dCounter = dCounter + 1 Loop iColumn = iColumn + 1 Return iColumn End Function Sub CMM_93Cam(ByVal wbTempName As Workbook) ' ' CMM_93Cam Macro ' This subroutine imports data from the CMM Report for a 195C93 Cam flatness measurement into this file. ' iColumn = FindEmptyColumn() Basically, I get an error when I type the "Return iColumn" statement. How do I get the function to return the value I have stored in iColumn? excel vba share|improve this question edited Sep 11 '15 at 2:42 pnuts 33.7k63569 asked Jan 24 '14 at 20:03 ilarson007 87211 3 To return value from function, you should use function name: write FindEmptyColumn = iColumn instead Return iColumn –simoco Jan 24 '14 at 20:03 add a comment| 1 Answer 1 active oldest votes up vote 4 down vote accepted The Return statement in VBA does not return the results of a function. Use the function name instead. Instead of: Return iColumn Use: FindEmptyColumn = iColumn In VBA, the Return statement is only used in conjunction with GoSub. MSDN: GoSub...Return Statement share|impr
activation email? 1 Hour 1 Day 1 Week 1 Month Forever Login with username, password and session length Forum only search News: Home Help Login Register Computer Hope » Software » Computer programming » Visual Basic - Trying to fix "End of statement expected" « previous next » Print Pages: [1] Go Down Author Topic: Visual Basic - Trying to fix "End of statement expected" (Read 12213 times) 0 Members and 5 Guests are viewing this topic. simplyTechy100Topic StarterRookieThanked: 1 Experience: Expert OS: Windows 7 Visual Basic - Trying to fix "End of statement expected" « on: April 03, 2014, 05:59:02 PM » I am trying to make a Visual Basic OS but I get 3 errors on Login.vb that are all "End of statement expected.Code: [Select]Public Class Login
#If TextBox1.Text == Administrator Then
TextBox2.Text == AdminSuper32
#End If
#If Button1.Click Then
Desktop.Show()
#End If
#If TextBox1.Text == Administrator & TextBox2.Text == AdminSuper32 Then
DeskAdmin.Show()
#End If
End ClassI have all 2 .vb's created. (both fullscreen)This is causing me to post here.If I revert to (last functional state) or whatever it will remove the #If's that I need for logon, administrator check and Auto-Admin Logon (type Administrator, and poof, the password!)I am not sure I can send you the "errored" program. But if you want, I think I can send the Login.vb!EDIT: Here is the Login.vb. Logged BC_ProgrammerMastermind Typing is no substitute for thinking.Thanked: 956 Certifications: List Computer: Specs Experience: Beginner OS: Windows 7 Re: Visual Basic - Trying to fix "End of statement expected" « Reply #1 on: April 03, 2014, 07:57:01 PM » -Your If statements are all compile-time conditional compilation.-None of the executable code exists in a method.-Neither Administrator or AdminSuper32 are valid identifiers. You probably meant to quote them.-Visual Basic doesn't have a & operator.-Visual Basic doesn't have a == operator.even changing all of that to:Code: [Select]Public Class Login
Pub