Compile Error Expected End Sub In Excel
Contents |
Forums Excel Questions Compile Error: Expected End Sub Page 1 of 2 12 Last Jump to page: Results 1 to 10 of 11 Compile Error: Expected End SubThis is a discussion on Compile compile error expected end with vba Error: Expected End Sub within the Excel Questions forums, part of the Question Forums compile error expected end of statement category; Hi!! Prefaced with I am a novice!!! But I am trying to get the macro below to work in Excel
Compile Error Expected End Of Statement Macro
... LinkBack LinkBack URL About LinkBacks Bookmark & Share Digg this Thread!Add Thread to del.icio.usBookmark in TechnoratiTweet this thread Thread Tools Show Printable Version Display Linear Mode Switch to Hybrid Mode Switch to
Compile Error Expected End Of Statement Visual Basic
Threaded Mode Jan 4th, 2012,12:25 PM #1 jzkemler1 New Member Join Date Jan 2012 Posts 13 Compile Error: Expected End Sub Hi!! Prefaced with I am a novice!!! But I am trying to get the macro below to work in Excel and I keep getting the Compile Error: Expected End Sub error. Can anyone with a trained set of eyes help me out? Thanks so much!! Zoe Sub ctrln() compile error expected end with ' ' ctrln Macro ' ' Keyboard Shortcut: Ctrl+n ' Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 Then Exit Sub If Not Intersect(Target, Range("G34")) Is Nothing Then With Target If IsNumeric(.Value) And Not IsEmpty(.Value) Then Range("I34").Value = Range("I34").Value + Range ("G34").Value End If End With End If End Sub Share Share this post on Digg Del.icio.us Technorati Twitter Reply With Quote Jan 4th, 2012,12:26 PM #2 shg MrExcel MVP Join Date May 2008 Location The Great State of Texas Posts 18,545 Re: Compile Error: Expected End Sub Welcome to the board. Remove the lines that appear above Private Sub ... Share Share this post on Digg Del.icio.us Technorati Twitter Microsoft MVP - Excel Reply With Quote Jan 4th, 2012,12:29 PM #3 jasonb75 Board Regular Join Date Dec 2008 Posts 6,313 Re: Compile Error: Expected End Sub You have part of what looks like a recorded macro followed by an event procedure. You just need Code: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 Then Exit Sub If Not Intersect(Target, Range("G34")) Is Nothing Then With Target If IsNumeric(.Value) And Not IsEmpty(.Value) Then Range("I34").Value = Range("I34").Value + Range("G34").Value End If End With End If End Sub not the part above it. Share Share
»excelcommentsWant to join? Log in or sign up in seconds.|Englishlimit my search to /r/exceluse the following search parameters
Compile Error Block If Without End If
to narrow your can't execute code in break mode results:subreddit:subredditfind submissions in "subreddit"author:usernamefind submissions by sub vba "username"site:example.comfind submissions from "example.com"url:textsearch for "text" in urlselftext:textsearch for "text" http://www.mrexcel.com/forum/excel-questions/602867-compile-error-expected-end-sub.html in self post contentsself:yes (or self:no)include (or exclude) self postsnsfw:yes (or nsfw:no)include (or exclude) results marked as NSFWe.g. subreddit:aww site:imgur.com dogsee https://www.reddit.com/r/excel/comments/3g1phy/vba_macro_throwing_an_expected_end_sub_error_not/ the search faq for details.advanced search: by author, subreddit...this post was submitted on 06 Aug 20151 point (100% upvoted)shortlink: remember mereset passwordloginAsk an Excel Question!excelsubscribeunsubscribe50,982 readers~63 users here now all new Solved Unsolved Waiting Discussion Pro Tip Templates Add-in PLEASE FULLY READ THE SIDE-BAR BEFORE SUBMITTING A POST! Where to Learn Excel & Advice Megathread Submission Guidelines and Sharing Questions Frequ
+ Ask a Question Need help? Post your question and get tips & solutions from a community https://bytes.com/topic/visual-basic/answers/907558-how-fix-compile-error-expected-end-sub-vba-macro of 418,469 IT Pros & Developers. It's quick & easy. How to http://www.vbforums.com/showthread.php?736775-RESOLVED-Visual-basic-S-error-quot-Compile-Error-Expected-End-Sub-quot-and-where-it-comes fix "Compile error: Expected End Sub" in VBA Macro? P: 1 Dorota Prywata Hi, I need help with VBA Macro for Auto-filter to high lite a header plp advice as per below course a I got Compile error: Expected End Sub ? Expand|Select|Wrap|Line Numbers SubMacro1() FunctionFilterOn(myCellAsRange)AsBoolean OnErrorResumeNext WithmyCell.Parent.AutoFilter With.Filters(myCell.Column-.Range.Column+1) compile error If.OnThenFilterOn=True EndWith EndWith EndFunction EndSub Thanks, D Feb 3 '11 #1 Post Reply Share this Question 1 Reply Expert Mod 2.5K+ P: 2,543 Stewart Ross You can't define a function (lines 3-10) WITHIN the definition of a SUB (lines 1 and 12). You can CALL the function from the sub, but they must be separately defined. -Stewart Feb 3 '11 #2 reply compile error expected Message Cancel Changes Post your reply Join Now >> Sign in to post your reply or Sign up for a free account. Similar topics How to fix "Compile Error Expected: end of statement" in a query? How to fix error when executing macro: "Compile Error Variable not defined"? Delete Record Button and Getting a "compile error" Right turns to RIGHT and I get "Compile Error -Expected Array "on error resume next" does not work! "instantiated from here" compile error when using template "Use of possibly unassigned field" compile error What would cause"Compile error in hidden module" docmd.RunSQL Update records in table how can I get rid of the "You are about to update" message Browse more Visual Basic 4 / 5 / 6 Questions on Bytes Question stats viewed: 8200 replies: 1 date asked: Feb 3 '11 Follow this discussion BYTES.COM © 2016 Formerly "TheScripts.com" from 2005-2008 About Bytes | Advertise on Bytes | Contact Us Sitemap | Visual Basic 4 / 5 / 6 Answers Sitemap | Visual Basic 4 / 5 / 6 Insights Sitemap Follow us to get the Latest Bytes Updates
" Compile Error : Expected End Sub" and where it comes? 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 11 of 11 Thread: [RESOLVED] Visual basic'S error " Compile Error : Expected End Sub" and where it comes? Tweet Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode Oct 2nd, 2013,07:52 AM #1 ilke View Profile View Forum Posts Thread Starter New Member Join Date Oct 2013 Posts 7 [RESOLVED] Visual basic'S error " Compile Error : Expected End Sub" and where it comes? Please can someone tell me where i am making mistake? Visual basic is giving error , it is sayin " Compile Error : Expected End Sub " I am new with this program. I searched on the internet. I am using Private Sub or function wrongly i think. I put end but it still saying "End Sub". Codes: Private Sub Form_Load() Dim i As Integer Dim x(1 To 100) As Double ir = 0 x(1) = 2: x(2) = 3: AERROR = 0.001 Public Function f(ByVal x As Double) As Double fx(i - 2) = x(i - 2) ^ 2 fx(i - 1) = x(i - 1) ^ 2 End Function End Sub Public Sub Calculate_Click() For i = 3 To 100 x(i) = x(i - 1) - ((fx(i - 1) * (x(i - 1) - x(i - 2))) / (fx(i - 1) - fx(i - 2))) If Abs(x(i) - x(i - 1)) < AERROR Then GoTo Solution ir = ir + 1 Next i Solution Print Sonuç = x(i), ir End Sub Reply With Quote Oct 2nd, 2013,08:15 AM #2 techgnome View Profile View Forum Posts PowerPoster Join Date May 2002 Posts 29,763 Re: Visual basic'S error " Compile Error : Expected End Sub" and where it comes? you're trying to put a function inside of a sub... you can't do that... also, your function as it is, doesn't return anything... further complicating it, your function uses a variable array fx that's undefined... the short of it, there's a lot more than just a "missing" end sub here... I'd try to fix it, but I don't know what it's doing, what it's supposed to do or what fx() is supposed to be... so I'm not sure where to start. -tg * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.* * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.* * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft * * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers *