+ Reply to Thread
Results 1 to 8 of 8

Address function Sub or Function not defined

  1. #1
    Registered User
    Join Date
    05-07-2020
    Location
    Albany, NY
    MS-Off Ver
    2007
    Posts
    7

    Address function Sub or Function not defined

    I put this formula in a cell: =Address(5, 6, 2) and the cell displays F$5 (row 5, 6th col, absolute row, relative column) as I expect. But when I create the following Sub:
    Please Login or Register  to view this content.
    and then double click any cell, I get this message displayed: "Compile Error: Sub or Function not defined" with the word Address highlighted.
    In searching the web, I found reference to needing to add the Solver reference under Tools/References. When I open Tools/References, I see a list with "Visual Basic For Applications", "Microsoft Excel 16.0 Object Library", "OLE Automation", and "Microsoft Office 16.0 Object Library" checked, and 200 or more items unchecked. But I cannot find "Solver."
    All the references I find about using Address show it as ADDRESS. When I enter it in all caps or all lower case, it changes it to initial cap only, so it seems to recognize the word. Am I doing something wrong, or am I missing a library?

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,787

    Re: Address function Sub or Function not defined

    You cannot use that worksheet function directly in VBA, try
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-07-2020
    Location
    Albany, NY
    MS-Off Ver
    2007
    Posts
    7

    Re: Address function Sub or Function not defined

    Thanks. I never would have figured it out. I see that the Address property (1,0) is RowAbsolute true and ColumnAbsolute false. The second version is more intuitive to me, but I've never heard of using square brackets.

  4. #4
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,787

    Re: Address function Sub or Function not defined

    You're welcome & thanks for the feedback.

    The square brackets are a shorthand version of the Evaluate function

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Address function Sub or Function not defined


    As a VBA beginner starter :

    PHP Code: 
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As RangeCancel As Boolean)
        
    MsgBox Target.Address(TrueFalse)
    End Sub 
    ► Do you like it ? ► ► So thanks to click on bottom left star icon « Add Reputation » ! ◄ ◄

  6. #6
    Registered User
    Join Date
    05-07-2020
    Location
    Albany, NY
    MS-Off Ver
    2007
    Posts
    7

    Re: Address function Sub or Function not defined

    Thanks for all your help. I'm still developing this. I've been programming for 20 years, and took a class in VB a while ago, but I have trouble wrapping my head around referencing objects/properties. I have the following module:
    Please Login or Register  to view this content.
    When I double click on W9 I get a Message with "W$9" for the first and second messages. The third gives me a Type mismatch error. When I "mouse over" the words Target.Row and Target.Column I see "9" and "23" respectively. The first and third lines seem to be the same to me. What "type" is expected and what "type" was found, causing the mismatch?

    I was going to mark this SOLVED, but (1) I had this additional question, and (2), I can't find the place in the forum to mark it SOLVED. Thanks.

  7. #7
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,787

    Re: Address function Sub or Function not defined

    When using the [] notation, you cannot use variables, ie Target.row.

    To mark a thread as solved click on the "Thread tools" button at the top of the thread.

  8. #8
    Registered User
    Join Date
    05-07-2020
    Location
    Albany, NY
    MS-Off Ver
    2007
    Posts
    7

    Re: Address function Sub or Function not defined

    Thanks, and I hope I don't need to bug you again.

+ 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] How to make VBA function “VBA only” and disable it as User defined function
    By JimmyWilliams in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-17-2018, 07:29 PM
  2. [SOLVED] Usage of standard functions into custom function (or user defined function)
    By tusharb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-13-2016, 12:43 AM
  3. Replies: 1
    Last Post: 06-02-2015, 01:38 AM
  4. COUNTIF/COUNTIFS function + nested user-defined function
    By shamjamali in forum Excel General
    Replies: 1
    Last Post: 05-12-2015, 09:12 PM
  5. [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
  6. 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
  7. Need to open the Function Arguments window from VBA for a user defined function.
    By korrin.anderson@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-20-2006, 10:55 AM

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