Compile Error Argument Not Optional
Contents |
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 compile error argument not optional vba excel more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags
Compile Error Argument Not Optional Access
Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you,
Compile Error Argument Not Optional Vba
helping each other. Join them; it only takes a minute: Sign up VBA Function - Argument Not Optional up vote 3 down vote favorite Public Function RETURN_Equipment(Optional category As String) As Collection Dim config As classConfiguration Set config
Compile Error Argument Not Optional Vb
= New classConfiguration Dim item As classItem Set item = New classItem Dim myCollection As Collection Set myCollection = New Collection For Each config In Configurations For Each item In config.colItems If IsMissing(category) Then myCollection.add item ElseIf InStr(category, "mainframe") <> 0 And item.category = "mainframe" Then myCollection.add item MsgBox "Fired!" ElseIf category = "accessory" And item.category = "accessory" Then Else End If Next Next RETURN_Equipment = myCollection End Function I keep getting Compile error: Argument not compile error argument not optional setwarnings optional I get the error on the last line RETURN_Equipment = myCollection I understand the error message, its telling me I did not fill out a parameter. But I only have one parameter, and I've declared it optional. It looks like the code thinks I'm trying to call the function from the function? What gives? excel vba share|improve this question edited May 9 '14 at 21:22 GSerg 47.8k775128 asked May 9 '14 at 21:14 user3403175 32117 possible duplicate of What does the keyword Set actually do in VBA? –Brad May 9 '14 at 21:18 stackoverflow.com/q/5965593/11683 –GSerg May 9 '14 at 21:20 The default 'value' of collection is .Item which requires an index. To assign the reference of the collection object to a variable you need to use the Set keyword at the start of the line. –Cor_Blimey May 9 '14 at 21:31 add a comment| 3 Answers 3 active oldest votes up vote 7 down vote accepted Anytime you assign an object you need to use the set keyword. set RETURN_Equipment = myCollection share|improve this answer answered May 9 '14 at 21:16 Brad 7,82821951 1 Worked like a charm, thank you! Now that you've pointed it out it makes complete sense. –user3403175 May 12 '14 at 19:43 add a comment| up vote 1 down vote I was getting this e
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 vba not optional company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions visual basic compile error argument not optional Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million compile error named argument not found programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Compile error. Argument not optional up vote 0 down vote favorite I'm sure you will find the problem that I'm http://stackoverflow.com/questions/23574083/vba-function-argument-not-optional uncapable to do. Below you can see a resume of the code in which I have the problem. After changing the value in the combobox1 it shows an error "Compile error. Argument not optional", highlighting in yellow "Sub ComboBox1_Change()" and in blue "Call TextBox4_Exit". I think I'm doing something wrong with the arguments needed but don't know how to handle. Thank you for your help. Sub ComboBox1_Change() If TextBox4.Visible = True And TextBox4.Value <> http://stackoverflow.com/questions/21111472/compile-error-argument-not-optional "" Then Call TextBox4_Exit End If Sub TextBox4_Exit(ByVal cancel As MSForms.ReturnBoolean) Dim placas As String placas = TextBox4.Value I = 3 While Range("E" & I).Value <> "" If Range("E" & I).Value = mensaje Then If Range("L" & I).Value = mensaje2 Then If sheet1 = "SIC" Then Range("X" & I).Value = placas TextBox11.Value = Range("Y" & I).Value TextBox10.Value = Range("Z" & I).Value Else Range("U" & I).Value = placas TextBox11.Value = Range("AN" & I).Value End If End If End If I = I + 1 Wend End Sub vba optional-parameters share|improve this question edited Jan 14 '14 at 10:47 twj 44429 asked Jan 14 '14 at 10:41 user3176668 312 add End Sub before this line Sub TextBox4_Exit(...). –KazimierzJawor Jan 14 '14 at 10:52 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote First, the Sub TextBox4_Exit(ByVal cancel As MSForms.ReturnBoolean) has one argument and it's not marked as Optional,so you need to pass a parameter to Call TextBox4_Exit. Second, did you miss your End Sub of ComboBox1_Change()? share|improve this answer answered Jan 14 '14 at 10:55 vutran 38416 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post
not optional If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above http://www.vbforums.com/showthread.php?473038-RESOLVED-compile-error-argument-not-optional to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 13 of 13 Thread: [RESOLVED] compile error: argument not optional Tweet Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Jun 8th, 2007,09:03 AM #1 loverman210 View Profile View Forum Posts Thread Starter Junior Member Join Date Jun 2007 compile error Posts 17 [RESOLVED] compile error: argument not optional Hello to everyone! I'm new to programming, and in fact I'm so new that I even need some help to start programming!! Using VB 6.0 this is the code: Private Sub Command1_Click() MsgBox ''hello'' End Sub that's all! then I run it and get the message: ''compile error: argument not optional'' any help would be much appreciated! thanks in advance!! using WinXP compile error argument Sp2 and Visual Basic 6 classic Reply With Quote Jun 8th, 2007,09:08 AM #2 Hack View Profile View Forum Posts Super Moderator Join Date Aug 2001 Location Searching for mendhak Posts 58,335 Re: compile error: argument not optional Welcome to the forums. Code: Private Sub Command1_Click() MsgBox "Hello" End Sub That works just fine. There has to be something else going on in your program. Does this error occur when you click the button or when you start your project? Please use [Code]your code goes in here[/Code] tags when posting code. When you have received an answer to your question, please mark it as resolved using the Thread Tools menu. Before posting your question, did you look here? Got a question on Linux? Visit our Linux sister site. I dont answer coding questions via PM or EMail. Please post a thread in the appropriate forum section. Creating A Wizard In VB.NET Paging A Recordset What is wrong with using On Error Resume Next Good Article: Language Enhancements In Visual Basic 2010 Upgrading VB6 Code To VB.NET Microsoft MVP 2005/2006/2007/2008/2009/2010/2011/2012/Defrocked Reply With Quote Jun 8th, 2007,09:13 AM #3 RhinoBull View Profile View Forum Posts PowerPoster Join Date Mar 2004 Location New Amsterdam Posts 24,135 Re: compile error: argument not optional Press