+ Reply to Thread
Results 1 to 6 of 6

Sub or function not defined

  1. #1
    Registered User
    Join Date
    01-03-2015
    Location
    mumbai
    MS-Off Ver
    maharashtra
    Posts
    3

    Sub or function not defined

    Hello all,

    I am new to VBA programming, I was trying to run a simple program with msgbox function in it but it is giving a compile error: "Sub or Function not defined".
    If I comment lines containing msg or msgbox function program runs without error. Please help me to solve this problem.

    Thanks in Advance
    Sandeep

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Sub or function not defined

    Hi Sandeep
    Welcome to the forum

    Please post your code here to let others help you
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Registered User
    Join Date
    01-03-2015
    Location
    mumbai
    MS-Off Ver
    maharashtra
    Posts
    3

    Re: Sub or function not defined

    Public Sub convertformula()
    '
    ' convertformula Macro
    ' for paste special
    '
    ' Keyboard Shortcut: Ctrl+Shift+C
    '
    Answer -MsgBox("convert formula to values?", vbYesNo)
    If Answer <> vbNo Then Exit Sub

    Selection.Copy
    Range("H5").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    End Sub

  4. #4
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Sub or function not defined

    It should probably be Answer = Msgbox, you have Answer -Msgbox.
    Click the * Add Reputation button in the lower left hand corner of this post to say thanks.

    Don't forget to mark this thread SOLVED by going to the "Thread Tools" drop down list above your first post and choosing solved.

  5. #5
    Registered User
    Join Date
    01-03-2015
    Location
    mumbai
    MS-Off Ver
    maharashtra
    Posts
    3

    Re: Sub or function not defined

    Thanks it worked

  6. #6
    Forum Expert skywriter's Avatar
    Join Date
    06-09-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    2,760

    Re: Sub or function not defined

    Thanks for the rep. points.

    If your original request is fulfilled please click the Thread Tools drop down box above your first post and choose solved.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] User defined function returns an error on a standard function used in it.
    By pb48 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-23-2013, 01:35 PM
  2. [SOLVED] Run Time 1004 - App Defined or Object defined error with String defined path structure
    By sarails in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-11-2012, 09:38 PM
  3. Application Defined or Object Defined Error, Command Button and Vlookup Function
    By stevedomer in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-14-2011, 11:20 PM
  4. [SOLVED] Excel - User Defined Function Error: This function takes no argume
    By BruceInCalgary in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-18-2006, 04:05 PM
  5. Replies: 0
    Last Post: 06-20-2006, 10:55 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1