Compile Error Expected End Sub Vba
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and vba compile error expected end of statement policies of this site About Us Learn more about Stack Overflow the
Excel Compile Error Expected End Sub
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags compile error expected end with Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only
Compile Error Expected End With Vba
takes a minute: Sign up VBA Error: “Compile error: Expected End Sub” up vote 1 down vote favorite Trying to pass "GetFullNamePDF()" to the Filename attribute, but getting the following error: "Compile error: Expected End Sub" Sub PrintPDF() Function GetFullNamePDF() As String GetFullNameCSV = Replace(ThisWorkbook.FullName, ".xlsm", ".pdf") End Function ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ "GetFullNamePDF()", Quality:=xlQualityStandard, IncludeDocProperties _ :=True, IgnorePrintAreas:=False, OpenAfterPublish:=False End compile error block if without end if Sub I know nothing about VBA, and got the above code from a question I asked yesterday, but was unable to test at the time. Guessing the error has to do with the function, since the code works without the function added and the filepath/name hard coded. Idea of the code is to dynamically use the filename of itself to name the path and file for the PDF. If you have any questions, just comment -- thanks! excel vba share|improve this question asked Dec 17 '10 at 15:40 blunders 1,58272759 add a comment| 3 Answers 3 active oldest votes up vote 3 down vote accepted You can't nest a function inside a procedure. You need to move it above: Function GetFullNamePDF() As String GetFullNameCSV = Replace(ThisWorkbook.FullName, ".xlsm", ".pdf") 'This should be GetFullNamePDF = Replace(ThisWorkbook.FullName, ".xlsm", ".pdf") End Function Sub PrintPDF() 'Remove the quotes from GetFullNamePDF ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ GetFullNamePDF(), Quality:=xlQualityStandard, IncludeDocProperties _ :=True, IgnorePrintAreas:=False, OpenAfterPublish:=False End Sub share|improve this answer answered Dec 17 '10 at 15:44 kgiannakakis 76k16124166 Thanks for taking the time to read the co
Forums Excel Questions Compile Error: Expected End Sub Page 1 of 2 12 Last Jump to page: Results 1 to 10 of
Compile Error Expected End Of Statement
11 Compile Error: Expected End SubThis is a discussion on Compile Error:
Can't Execute Code In Break Mode
Expected End Sub within the Excel Questions forums, part of the Question Forums category; Hi!! Prefaced with private sub I am a novice!!! But I am trying to get the macro below to work in Excel ... LinkBack LinkBack URL About LinkBacks Bookmark & Share Digg this http://stackoverflow.com/questions/4472095/vba-error-compile-error-expected-end-sub 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 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 http://www.mrexcel.com/forum/excel-questions/602867-compile-error-expected-end-sub.html 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() ' ' 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 h
»excelcommentsWant to join? Log in or sign up in seconds.|Englishlimit my search to /r/exceluse the following search parameters to narrow your results:subreddit:subredditfind submissions in "subreddit"author:usernamefind submissions by "username"site:example.comfind submissions from "example.com"url:textsearch for "text" in urlselftext:textsearch for https://www.reddit.com/r/excel/comments/3g1phy/vba_macro_throwing_an_expected_end_sub_error_not/ "text" in self post contentsself:yes (or self:no)include http://www.vbforums.com/showthread.php?736775-RESOLVED-Visual-basic-S-error-quot-Compile-Error-Expected-End-Sub-quot-and-where-it-comes (or exclude) self postsnsfw:yes (or nsfw:no)include (or exclude) results marked as NSFWe.g. subreddit:aww site:imgur.com dogsee the search faq for details.advanced search: by author, subreddit...this post was submitted on 06 Aug 20151 point (100% upvoted)shortlink: compile error remember mereset passwordloginAsk an Excel Question!excelsubscribeunsubscribe50,981 readers~56 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 compile error expected Questions Frequently Used Formulas Awarding ClippyPoints Thread flair: unsolved/solved Common VBA Mistakes /r/excel Guides and Write-ups /r/excel Wiki MICROSOFT COLLABORATION POST SOLVED? PLEASE SET THE FLAIR TO SOLVED! OPs should consider giving helpful users a ClippyPoint by replying to their comment with Solution Verified TO APPLY CODE FORMATTING Use 4 spaces to start each line You can select code in your VBA window, press Tab, then copy and paste into your thread or comment. Recent ClippyPoint Milestones! Congratulations and thank you to these contributors Date User CP 2016.10.04 mac-0 10 2016.09.29 excelevator 400 2016.09.27 captcha_bot 10 2016.09.26 continue_stocking 10 2016.09.23 sqylogin 50 2016.09.22 Bechara 10 2016.09.19 yeahnahnahyeahnahhh 10 2016.09.15 outer_sect_disciple 10 2016.0
" 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 lo