+ Reply to Thread
Results 1 to 11 of 11

Invalid name error when using function

  1. #1
    Registered User
    Join Date
    08-29-2013
    Location
    Sacramento
    MS-Off Ver
    Excel 2007
    Posts
    6

    Invalid name error when using function

    So I total new at VBA. I'm using the Excel 2007 Bible to get started and the information is a bit overwhelming. This is probably a really stupid question to ask but here is my problem.

    I have been experimenting with functions. I created a functions using a Select Case Construct.

    The function worked perfectly when I typed it in. I saved/closed my workbook and took a break.

    I reopened my work book and tried the function again and I receieved an Invalid Name Error.

    Thoughts?
    Last edited by Davidwebb526; 08-29-2013 at 11:24 AM.

  2. #2
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Total Noob at VBA

    What is the name of your function? How are you calling it?
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  3. #3
    Registered User
    Join Date
    08-29-2013
    Location
    Sacramento
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Total Noob at VBA

    I just called it "NumSign" and I'm calling it in the Fx field as "=NumSign()"

  4. #4
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: Total Noob at VBA

    First off, the thread title doesn't really comply with Rule 1 of the forum, so technically I probably shouldn't answer, but this is a gimme, and I really don't want to discourage you from asking questions on the forums.

    Check to see if macros are enabled... Custom functions are stored the same way macros are, so they need to be abled when opening up excel.

    Additionally, it also matters where you stored the function. If you created a personal.xlsm file, if you open up a second instance of excel, it may not be able to read those custom functions due to it already being opened by the first instance (basically, if you click the excel executable twice, it'll open two windows of excel, rather than many workbooks within one big excel window).

    Lastly, a tip when starting to work in VBA... just check out a lot of the posts on these forums for ideas for the code itself. A lot of the gurus here have some ridiculous VBA experience, and write some ridiculously complex, compact functions that'll impress you.
    Going for Guru! Click the Star to the bottom left of this post if I helped!

  5. #5
    Registered User
    Join Date
    08-29-2013
    Location
    Sacramento
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Total Noob at VBA

    First of all I apologize for my indescretion with rule 1. Most forums usually have the same generic rules with regards to language and harassment. I'll be sure to follow protocol with future threads.

    My macros are enabled and my module where my original code was input, open with the workbook. So it would appear that the location is fine.

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Total Noob at VBA

    David,

    Please amend your thread title as suggested by Miraun before others can proceed to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  7. #7
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Total Noob at VBA

    I believe functions created in the VBE have to be called through code. Such as:
    Please Login or Register  to view this content.
    e/ My mistake arlu, I hit reply before I saw your request.
    Last edited by Solus Rankin; 08-29-2013 at 11:24 AM.

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Total Noob at VBA

    Quote Originally Posted by XeRo Solus View Post
    I believe functions created in the VBE have to be called through code.
    Nope. You can call them from cells as long as they are in a normal module.
    Remember what the dormouse said
    Feed your head

  9. #9
    Valued Forum Contributor Miraun's Avatar
    Join Date
    04-03-2009
    Location
    New England
    MS-Off Ver
    2003, 2007, 2010, 2013
    Posts
    554

    Re: Invalid name error when using function

    At this point, probably best to attach a sample workbook using the advanced posting functions of the forum so we can take a full look at what's happening.

  10. #10
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Invalid name error when using function

    Nope. You can call them from cells as long as they are in a normal module.
    I knew I shouldn't have been so certain.

  11. #11
    Registered User
    Join Date
    08-29-2013
    Location
    Sacramento
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Invalid name error when using function

    Good news and bad news.

    Good news-Problem solved! I needed to create a trusted location and save my workbook there.

    Bad news-Basically it meant my macros were not being enabled so I feel like dummy.

    Thanks everyone.

+ 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. Complete and total Noob!
    By bdavis711 in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 09-07-2012, 04:27 PM
  2. Total Excel Noob with what is probably very easy question
    By milkmoney11 in forum Excel General
    Replies: 2
    Last Post: 03-14-2009, 11:34 AM
  3. Total NOOB LOOP
    By nabsibouch in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-16-2009, 10:12 PM
  4. HELP for a total noob
    By Dagz in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 03-24-2008, 01:03 AM
  5. VBA Noob ,please !
    By kamiland in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 01-17-2007, 02:53 PM

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