Compile Error For Without Next
Contents |
Forums Excel Questions Compile error: For without Next Page 1 of 5 123 ... Last Jump to page: Results 1 to 10 of 42 Compile error: For without NextThis is a discussion on Compile error: For without Next within the Excel Questions forums, part of the Question Forums compile error for without next excel vba category; i am consistantly getting a Compile error: saying: For Without Next. what does this mean and
Compile Error For Without Next Vba
how can i resolve ... LinkBack LinkBack URL About LinkBacks Bookmark & Share Digg this Thread!Add Thread to del.icio.usBookmark in TechnoratiTweet this thread Thread excel compile error expected end sub Tools Show Printable Version Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Feb 21st, 2003,04:57 AM #1 NewbieVBie Board Regular Join Date Jan 2003 Location south london Posts 65 i am consistantly getting a Compile error: saying: For Without
Expected End With Error
Next. what does this mean and how can i resolve it? (the debug highlights the End Sub line of the code) Share Share this post on Digg Del.icio.us Technorati Twitter Reply With Quote Feb 21st, 2003,05:07 AM #2 dk MrExcel MVP Join Date Feb 2002 Location Sydney, Australia Posts 2,932 It's probably because you have a For loop and haven't correctly structured it with a Next e.g. example of incorrect For Next : Sub Test() For x = 1 To 5 MsgBox "Value of compile error end if without block if x is " & x End Sub This should be: Sub Test() For x = 1 To 5 MsgBox "Value of x is " & x Next x End Sub I hope this makes sense. If not, it will help if you post your code. Share Share this post on Digg Del.icio.us Technorati Twitter Reply With Quote Feb 21st, 2003,05:16 AM #3 NewbieVBie Board Regular Join Date Jan 2003 Location south london Posts 65 to save duplicating the thread the code was posted by phantom 1975 on the other thread i started this morning at http://www.mrexcel.com/board/viewtop...rum=2&start=10 fourth post down [ This Message was edited by: NewbieVBie on 2003-02-21 05:16 ] Share Share this post on Digg Del.icio.us Technorati Twitter Reply With Quote Feb 21st, 2003,05:31 AM #4 dk MrExcel MVP Join Date Feb 2002 Location Sydney, Australia Posts 2,932 The code you mentioned compiles fine and doesn't have a For Next loop in it. Share Share this post on Digg Del.icio.us Technorati Twitter Reply With Quote Feb 21st, 2003,05:37 AM #5 NewbieVBie Board Regular Join Date Jan 2003 Location south london Posts 65 any ideas how/why i could be getting the error? Share Share this post on Digg Del.icio.us Technorati Twitter Reply With Quote Feb 21st, 2003,05:58 AM #6 dk MrExcel MVP Join Date Feb 2002 Location Sydney, Australia Posts 2,932 No. Can you post the code you are using, and the exact error message you get and where. The link to the thread you posted contains several different piece
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
Vba For Loop
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs
Emacs Compile Next Error
Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just for without next vba error like you, helping each other. Join them; it only takes a minute: Sign up Getting For Without Next Error, not sure why up vote 1 down vote favorite I'm trying to loop throw rows and say "if http://www.mrexcel.com/forum/excel-questions/39473-compile-error-without-next.html the cell in this column begins with 49, hide the entire row". Here's my code: For i = 2 To LastRow If Rows("AK" & i).Value Like "49*" Then Rows("AK" & i).EntireRow.Hidden = True Next i It keeps stopping on the last line and saying "For without next". Can it not see the FOR line three lines up? This is just one of many statements I have like this but I think fixing this one will http://stackoverflow.com/questions/6426295/getting-for-without-next-error-not-sure-why help me format the others. What am I doing wrong? excel-vba share|improve this question asked Jun 21 '11 at 13:44 Mr_Thomas 36711121 add a comment| 2 Answers 2 active oldest votes up vote 4 down vote accepted Your missing an End If (The wording is like that because It sees a Next within an If block without a matching For; which is illegal) For i = 2 To LastRow If Range("AK" & i).Value Like "49*" Then Range("AK" & i).EntireRow.Hidden = True End If Next i share|improve this answer edited Jun 21 '11 at 14:02 answered Jun 21 '11 at 13:48 Alex K. 106k16146194 I added the end if to the code, now it's giving me an application-defined or object-defined error on 2nd line. –Mr_Thomas Jun 21 '11 at 13:58 You need to replace Rows("AK" & i) with Range("AK" & i) –Alex K. Jun 21 '11 at 14:01 I missed that the first go at it. Your solution worked, thank you. –Mr_Thomas Jun 21 '11 at 14:10 add a comment| up vote 2 down vote End if is missing ! It is required if you put the next instruction on another line. share|improve this answer answered Jun 21 '11 at 13:48 iDevlop 14.4k44187 add a comment| Your Answer draft saved draft discarded Sign up or l
soon) Ruby (coming soon) Getting Started Code Samples Resources Patterns and Practices App Registration Tool Events Podcasts Training API Sandbox Videos Documentation Office Add-ins Office Add-in Availability https://msdn.microsoft.com/en-us/library/office/gg264122.aspx Office Add-ins Changelog Microsoft Graph API Office 365 Connectors Office 365 REST http://www.vbforums.com/showthread.php?337579-Compile-Error-Next-without-For APIs SharePoint Add-ins Office UI Fabric Submit to the Office Store All Documentation https://www.yammer.com/ http://feeds.feedburner.com/office/fmNx Office VBA language reference Visual Basic language reference Error Messages Error Messages Next without For Next without For Next without For #Else clause must be preceded by a matching #If #Else If, #Else, compile error or #End If must be preceded by a matching #If #ElseIf must be preceded by a matching #If or #ElseIf and followed by an #ElseIf, #Else, or #End 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 to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 16 of 16 Thread: Compile Error: Next without For Tweet Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode May 5th, 2005,08:25 AM #1 neilma View Profile View Forum Posts Thread Starter New Member Join Date May 2005 Posts 6 Compile Error: Next without For Hi, I am a novice at this and would appreciate any help. I get a Compile Error: Next without For message even though I do have a For. Here's the script: Dim myOscArray(10, 3) As Single Dim mySumflow As Single Dim myMeanflow As Single mySumflow = 0 j = 0 Set currentCell = Range("I11") For i = 1 To myDatasecs - 2 Set nextCell = currentCell.Offset(1, 0) Set currentCell = nextCell mySumflow = mySumflow + currentCell.Offset(0, -2).Value If j = 11 Then myMeanflow = mySumflow / i Exit For Else If currentCell.Formula <> "" Then myOscArray(j, 1) = currentCell.Value Else If currentCell.Offset(0, 1).Value <> "" Then myOscArray(j, 2) = currentCell.Value j = j + 1 Else Next i Thanks, Neil Reply With Quote May 5th, 2005,08:42 AM #2 Ecniv View Profile View Forum Posts Visit Homepage Don't Panic! Join Date Nov 2000 Location Excel Hell! Posts 5,036 Re: Compile Error: Next without For Originally Posted by neilma Hi, Code: Dim myOscArray(10, 3) As Single Dim mySumflow As Single Dim myMeanflow As Single mySumflow = 0 j = 0 Set currentCell = Range("I11") For i = 1 To myDatasecs - 2 Set nextCell = currentCell.Offset(1, 0) Set currentCell = nextCell mySumflow = mySumflow + currentCell.Offset(0, -2).Value If j = 11 Then myMeanflow = mySumflow / i Exit For Else If currentCell.Formula <> "" Then myOscArray(j, 1) = currentCell.Value Else If currentCell.Offset(0, 1).Value <> "" Then myOscArray(j, 2) = currentCell.Value j = j + 1 Else End if end if Next i You forgot to close your if statements BOFH Now, BOFH Past, Information on duplicates Feeling like a fly on the inside of a closed window (Thunk!) If I post a lot, it is because I am bored at work! ;D Or stuck... * Anything I post can be only