Compile Error Expected Array
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 compile error expected array in vba Learn more about Stack Overflow the company Business Learn more about hiring developers or compile error expected array vb6 posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow
Access Vba Compile Error Expected Array
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 EXCEL VBA Error: “Compile Error: Expected Array” up
Excel Macro Expected Array
vote 1 down vote favorite Can anyone help me? I have been getting a compile error (...: "Expected Array") when dealing with arrays in my Excel workbook. Basically, I have one 'mother' array (2D, Variant type) and four 'baby' arrays (1D, Double type). The called subroutine creates the publicly declared arrays which my main macro ends up using for display purposes. Unfortunately, the final of the baby arrays compile error expected = craps out (giving the "Compile Error: Expected Array"). Strangely, if I remove this final baby array ('final' - as in the order of declaration/definition) the 2nd to last baby array starts crapping out. Here is my code: Public Mother_Array() as Variant, BabyOne_Array(), BabyTwo_Array(), BabyThree_Array(), BabyFour_Array() as Double 'declare may other variables and arrays, too Sub MainMacro() 'do stuff Call SunRaySubRoutine(x, y) 'do stuff Range("blah") = BabyOne_Array: Range("blahblah") = BabyTwo_Array Range("blahbloh" = BabyThree_Array: Range("blahblue") = BabyFour_Array End Sub Sub SunRaySubRoutine(x,y) n = x * Sheets("ABC").Range("A1").Value + 1 ReDim Mother_Array(18, n) as Variant, BabyOne_Array(n), BabyTwo_Array(n) as Double ReDim BabyThree_Array(n), BabyFour_Array(n) as Double 'do stuff For i = 0 to n BabyOne_Array(i) = Mother_Array(0,i) BabyTwo_Array(i) = Mother_Array(2,i) BabyThree_Array(i) = Mother_Array(4,i) BabyFour_Array(i) = Mother_Array(6,i) Next End Sub I have tried to declare all arrays as the Variant type, but to no avail. I have tried to give BabyFour_Array() a different name, but to no avail. What's really strange is that even if I comment out the part which makes the BabyFour_Array(), the array still has zero values for each element. What's also a bit strange is that the first baby array never craps out (although, the 2nd one crapped out once (one time out
this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you
Compile Error Expected End With
can post: click the register link above to proceed. To start viewing compile error expected identifier messages, select the forum that you want to visit from the selection below. Results 1 to 14 of compile error expected identifier or bracketed expression 14 Thread: [RESOLVED] Expected Array??? Tweet Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Nov 20th, 2011,11:45 AM http://stackoverflow.com/questions/17255458/excel-vba-error-compile-error-expected-array #1 PaulTilley View Profile View Forum Posts Thread Starter Addicted Member Join Date Sep 2000 Location UK Posts 199 [RESOLVED] Expected Array??? I've just tried to compile my project and all of a sudden some functions that have been working perfectly are causing a compile error: one example: Code: Public Function StripCurrSymbol(StrIn As String) As String If Left(StrIn, 1) = "£" http://www.vbforums.com/showthread.php?665550-RESOLVED-Expected-Array Then StripCurrSymbol = Mid(FormatMoney(StrIn), 2) Else StripCurrSymbol = StrIn End If End Function another example is where im using a 'right'. The error I get is Compile Error: Expected Array and it highlights 'left' any ideas? Reply With Quote Nov 20th, 2011,11:52 AM #2 lone_REBEL View Profile View Forum Posts Hyperactive Member Join Date Jan 2006 Location Pakistan Posts 388 Re: Expected Array??? Its REALLY weird! VB sometimes does absurd things to me, too. Try closing and again opening the project and see if it compiles correctly. If not (as expected), can you post the value of StrIn variable when the error raises? (Taking the mouse cursor on it will display the value) If your problem is solved, then drag down the Thread Tools and mark your thread as Resolved. If I helped you solve your problem, inflate some air into my ego by rating my post and adding a comment too. For notorious issues (elaborate yourself) contact me via PM. I don't answer them in the forums EVER. Reply With Quote Nov 20th, 2011,11:53 AM #3 Spoo Vi
Forums Excel Questions VBA: compiler error: expected array OR expression not defined in context Results 1 to 6 of 6 VBA: compiler error: expected array OR expression not defined in contextThis is http://www.mrexcel.com/forum/excel-questions/700108-visual-basic-applications-compiler-error-expected-array-expression-not-defined-context.html a discussion on VBA: compiler error: expected array OR expression not defined in context http://forums.codeguru.com/showthread.php?258189-Compile-Error-expected-array-HELP-NEEDED within the Excel Questions forums, part of the Question Forums category; I'm having a problem with the code I'm writing. It doesn't compile. Compiler gives an error message saying "expected array" ... LinkBack LinkBack URL About LinkBacks Bookmark & Share Digg this Thread!Add Thread to del.icio.usBookmark in TechnoratiTweet this thread Thread Tools Show compile error Printable Version Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Apr 30th, 2013,08:27 AM #1 yky Board Regular Join Date Jun 2011 Posts 752 VBA: compiler error: expected array OR expression not defined in context I'm having a problem with the code I'm writing. It doesn't compile. Compiler gives an error message saying "expected array" at the following line: VoucherYear = Trim(Str(Year(VoucherDate))) The code first opens compile error expected a user form. I trace the code and everything works fine in the user form. After the user form, the control is transferred to add_voucher() in the main module. Once the control is transferred to the add_voucher() in the main module, in the debug window VoucherDate still shows as 30/4/2013 but Year(VoucherDate) shows "expression not defined in context" while in the userform1, the same function Year(VoucherDate) in the debug windows shows 2013. What is going on here? Any help would be greatly appreciated. Code: Public VoucherDate As Date Year(VoucherDate))) ' Last edited by yky; Apr 30th, 2013 at 08:29 AM. Share Share this post on Digg Del.icio.us Technorati Twitter Excel 2010, Windows 7 Reply With Quote Apr 30th, 2013,08:55 AM #2 Comfy Board Regular Join Date Dec 2009 Location Canterbury, UK Posts 3,208 Re: VBA: compiler error: expected array OR expression not defined in context What type of object is VoucherYear defined as in the process_userform1_selection sub? Share Share this post on Digg Del.icio.us Technorati Twitter Reply With Quote Apr 30th, 2013,09:22 AM #3 RoryA MrExcel MVPModerator Join Date May 2008 Location East Sussex Posts 28,295 Re: VBA: compiler error: expected array OR expression not defined in context Have you declared a
Forum Visual Basic Programming Visual Basic 6.0 Programming Compile Error : expected array - HELP NEEDED If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register or Login before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 2 of 2 Thread: Compile Error : expected array - HELP NEEDED Tweet Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode August 5th, 2003,08:05 AM #1 azwildcat4ever View Profile View Forum Posts Member Join Date Jul 2003 Posts 52 Compile Error : expected array - HELP NEEDED I have a Tree in functions and in my program I am trying to add an item to my tree structure. I am using and chaging the codes from another program which does treeitems add similar to what I want to do. However I am getting this error. I am fairly new to VB and need to know where i am going wrong. I am getting my error in the following Function called FindNewIndex. _______________________________________________ Public Function FindNewIndex(MyTV As TreeView, MyParent As Variant) Dim NodX As Node Biggest = 0 For Each NodX In MyTV.Nodes If Not (NodX.Parent Is Nothing) Then If NodX.Parent.Key = MyParent Then a = NodX.Key b = InStrRev(a, "*") c = CInt(Right(a, Len(a) - b)) ->>> ERROR If c > Biggest Then Biggest = c End If End If End If Next FindNewIndex = Biggest + 1 End Function ______________________________________________ THIS IS THE FUNCTION CALLING FindNewIndex Private Sub AssOpsFailModeAdd_Click() step2: temp = InputBox("Enter the name of the new failure mode", TV.SelectedItem.FullPath) If CheckInput(temp) = False Then GoTo step2 If temp = "" Then Exit Sub b = FindNewIndex(TV, TV.SelectedItem.Key) AddTVItem TV, TV.SelectedItem.Key, TV.SelectedItem.Key & "*" & b, temp, "Mode" TV.Nodes(TV.SelectedItem.Key & "*" & b).EnsureVisible End Sub Reply With Quote August 5th, 2003,10:16 AM #2 phinds View Profile View Forum Posts Senior Member Join Date Aug 2001 Posts 1,447 presumably the string a does not contain an integer at the time you do: c = CInt(Right(a, Len(a) - b)) ->>> ERROR what DOES a contain?