Compile Error Expected Sub Function Or Property 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 policies of this site About Us Learn more about Stack Overflow the company vba compile error expected end sub Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs vba compile error sub or function not defined Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, vba compile error expected function or variable just like you, helping each other. Join them; it only takes a minute: Sign up Excel VBA compile error: Expected Sub, Function or Property up vote 0 down vote favorite I am getting a compile error in compile error sub or function not defined Excel VBA which says Expected Sub, Function or Property. The function I am using is given below which is trying to copy the rate function in Excel. Thanks for your help. Function rate_m(nper As Double, pmt As Double, pv As Double, fv As Double, types As Double, guess As Double) As Variant Dim y, y0, y1, x0, x1, f, i As Double Dim FINANCIAL_MAX_ITERATIONS As Double Dim FINANCIAL_PRECISION As Double If IsNull(guess) Then guess
Vba Sub
= 0.01 If IsNull(fv) Then fv = 0 If IsNull(types) Then types = 0 FINANCIAL_MAX_ITERATIONS = 128 'Bet accuracy with 128 FINANCIAL_PRECISION = 0.0000001 '1.0e-8 y , y0, y1, x0, x1, f, i = 0 rate_m = guess If Abs(rate_m) < FINANCIAL_PRECISION Then y = pv * (1 + nper * rate_m) + pmt * (1 + rate_m * types) * nper + fv Else f = Exp(nper * Log(1 + rate_m)) y = pv * f + pmt * (1 / rate_m + types) * (f - 1) + fv y0 = pv + pmt * nper + fv y1 = pv * f + pmt * (1 / rate_m + types) * (f - 1) + fv End If 'find root by Newton secant method i , x0 = 0 x1 = rate_m While Abs(y0 - y1) > FINANCIAL_PRECISION & i < FINANCIAL_MAX_ITERATIONS rate_m = (y1 * x0 - y0 * x1) / (y1 - y0) x0 = x1 x1 = rate_m If Abs(rate_m) < FINANCIAL_PRECISION Then y = pv * (1 + nper * rate_m) + pmt * (1 + rate_m * types) * nper + fv Else f = Exp(nper * Log(1 + rate_m)) y = pv * f + pmt * (1 / rate_m + types) * (f - 1) + fv End If
here for a quick overview of the site Help Center Detailed answers to any
Vba Function
questions you might have Meta Discuss the workings and policies vba for loop of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack http://stackoverflow.com/questions/25141506/excel-vba-compile-error-expected-sub-function-or-property 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 compile error: expected sub, function, or property up vote 0 down vote favorite I'm trying to create a code which shows the texts of name, contact person, http://stackoverflow.com/questions/27686263/excel-vba-compile-error-expected-sub-function-or-property address, contact number, email and product order onto a worksheet, but i keep getting this compile error when after entering all the information into a userform and clicking OK, note: all the coding is on the OK command button. Private Sub cmdok_Click() 'activate worksheet Worksheets("CustomersOrders").Activate 'check if row empty NextRow = Application.WorksheetFunction.CountA(Range("A:A")) + 1 Cells(NextRow, 1) = txtName.Text Cells(NextRow, 2) = txtperson.Text Cells(NextRow, 3) = txtaddress.Text Cells(NextRow, 4) = txtcontact.Text Cells(NextRow, 5) = txtemail.Text Cells(NextRow, 6) = txtorder.Text If optYes Then Worksheets("SupportInfo").Activate NextRow Application.WorksheetFunction.CountA (Range("A:A")) + 1 Cells(NextRow, 1) = txtName.Text Cells(NextRow, 2) = txtperson.Text Cells(NextRow, 3) = txtaddress Cells(NextRow, 4) = txtcontact.Text Cells(NextRow, 5) = txtemail.Text Cells(NextRow, 6) = txtorder.Text Cells(NextRow, 7) = txtdeldate.Text End If 'clear the controls for next entry and set focus to Name txtName.Text = "" txtperson.Text = "" txtaddress.Text = "" txtcontact.Text = "" txtemail.Text = "" txtorder.Text = "" txtdeldate.Text = "" txtName.SetFocus 'hide the worksheets Worksheets("C
Way | Trading Add-ins For Excel | Convert Excel Into Calculating Web Pages Excel Web Pages | Produce Clean Efficient VBA http://www.ozgrid.com/forum/showthread.php?t=162229 Code Every Time | Build Automated Trading Models In Excel http://www.actuarialoutpost.com/actuarial_discussion_forum/showthread.php?t=252623 | Excel Web Pages | Excel Video Training Forum New Posts FAQ Calendar Forum Actions Mark Forums Read Quick Links Today's Posts What's New? Advanced Search Forum HELP FORUMS Excel General Compile Error Expected Sub, Function, or Property Excel Training / Excel Dashboards Reports If this compile error 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. If you don't like Google AdSense in the posts, register compile error expected or log in above. Click here to view the relaunched Ozgrid newsletter. Page 1 of 2 1 2 Last Jump to page: Results 1 to 10 of 12 Thread: Compile Error Expected Sub, Function, or Property Thread Tools Show Printable Version Search Thread Advanced Search February 9th, 2012 #1 vtflee View Profile View Forum Posts I agreed to these rules Join Date 9th February 2012 Posts 11 Compile Error Expected Sub, Function, or Property I am relatively new to coding in VBA and keep getting the compile error and cannot figure out why it keeps coming up. Any help on quelling the pop up would be helpful. Here is the code where I keep getting the error: VB: Sub tax() Tester = 0 livePriceTotal = Cells(lastLiveRow + 1, 2) liveTaxTotal = Cells(lastLiveRow + 1, 3) silentPriceTotal = Cells(lastSilentRow + 1, 7) silentTaxTotal = Cells(lastSilentRow + 1, 8) taxRate = Range("G1").Value taxExempt = Range("G2") taxRateAdj = ((liveTaxTotal + silentTaxTotal) * (100)) / (livePriceTotal + silentPriceTotal - taxExempt) Do If liveTaxTotal + sile
Today's Posts Search FlashChat Actuarial Discussion Preliminary Exams CAS/SOA Exams Cyberchat Around the World Suggestions Actuarial Jobs by State New York New Jersey Connecticut Massachusetts California Florida Texas Illinois Colorado Search Forums Show Threads Show Posts Tag Search Advanced Search Search Blogs Tag Search Advanced Search Go to Page... Thread Tools Display Modes #1 12-12-2012, 09:29 AM My Main ID Member CAS Join Date: Mar 2012 Posts: 96 Excel VBA - Calling another function I'm trying to do something incredibly simple, and don't know why I can't figure this out, even with the help of Googling. The goal is to have a VBA function that I can call during a sub. Can anyone tell me how to correct the code below? The error I'm getting when I run CallTheDamnFunction is that MakeString is "Compile Error: Expected Sub, Function, or Property." I've tried tons of different syntaxes, but can't get anything to work. Currently both the function and sub are housed in the same module; I've played around with that, but can't get it to make a difference. Function MakeString(iCol As Integer) As String MakeString = Chr(iCol) End Function Sub CallTheDamnFunction Dim iCol as integer iCol = 66 MakeString (iCol) End Sub My Main ID View Public Profile Find all posts by My Main ID #2 12-12-2012, 09:39 AM TwoStep Member CAS SOA Join Date: Oct 2008 Studying for All done! Posts: 913 You need to set a variable equal to the result of the function: Function MakeString(iCol As Integer) As String MakeString = Chr(iCol) End Function Sub CallTheDamnFunction Dim iCol as integer, s as string iCol = 66 s=MakeString(iCol) End Sub TwoStep View Public Profile Find all posts by TwoStep #3 12-12-2012, 10:18 AM Abused Student Member SOA Join Date: Feb 2007 Location: The Eighth Circle of Hell Favorite beer: Cold and lots of it Posts: 41,823 Agree with TwoStep. Since you set it up as a function, you need to have something set equal to it. The better way to code it IMHO seeing what you are trying to do is to change the function to a sub and just do "call makestring(icol)". __________________ GAME ON!!!!!!! Let your ness show. Join the D&D fun. Started but applications still accepted Officially assigned the role of Dictator, 9/30/09. Bow to my whims. Abused Student View Public Profile Find all posts by Abused Student #4 12-12-2012, 11:08 AM My Main ID Member CAS Join Date: Mar 2012 Posts: 96 Thank you both. Unfortunately, that doesn't seem to work. I tried both Range("A1").value = MakeString(iCol) ...and... Dim s as string s = MakeString(iCol) but neither works. The error I now get is