+ Reply to Thread
Results 1 to 9 of 9

Worksheet VBA function - not recognized

  1. #1
    Rowan
    Guest

    RE: Worksheet VBA function - not recognized

    There is nothing wrong with the function so it probably has to do with where
    you pasted it.

    If you place the function in a module and reference it on a worksheet in the
    same workbook then you can just type =celltype(A1). If you place the function
    in a workbook other than the one where you are going to use it then you must
    add the book name to the reference eg =PERSONAL.XLS!celltype(E18)

    Hope this helps
    Rowan


    "G Lykos" wrote:

    > Greetings! Am trying first experience of creating a VBA function that is
    > called via a cell formula in a worksheet, unsuccessfully so far.
    >
    > Steps have been to paste code into a workbook module such as:
    >
    > Function CellType(c)
    > ' Returns the cell type of the upper left
    > ' cell in a range
    > Application.Volatile
    > Set c = c.Range("A1")
    > Select Case True
    > Case IsEmpty(c): CellType = "Blank"
    > Case Application.IsText(c): CellType = "Text"
    > Case Application.IsLogical(c): CellType = "Logical"
    > Case Application.IsErr(c): CellType = "Error"
    > Case IsDate(c): CellType = "Date"
    > Case InStr(1, c.Text, ":") <> 0: CellType = "Time"
    > Case IsNumeric(c): CellType = "Value"
    > End Select
    > End Function
    >
    > I then enter a formula in a cell in a worksheet as =celltype(a1). The
    > function name does not get capitalized, suggesting that it wasn't located,
    > and the result is #NAME?, suggesting same thing. Something's not plugged in
    > somewhere, but I have no idea what. Help!
    >
    > Thanks,
    > George
    >
    >
    >


  2. #2
    Biff
    Guest

    Re: Worksheet VBA function - not recognized

    Hi!

    You're function does work (tried it) but you probably put it in the wrong
    place.

    Put it in a general module

    ALT + F11 to open the VBE
    CTRL + R to open the Project Explorer

    Find your workbook/project name

    Right click the name and selct Insert>Module

    Paste the code in the window that opens.

    Biff

    "G Lykos" <[email protected]> wrote in message
    news:[email protected]...
    > Greetings! Am trying first experience of creating a VBA function that is
    > called via a cell formula in a worksheet, unsuccessfully so far.
    >
    > Steps have been to paste code into a workbook module such as:
    >
    > Function CellType(c)
    > ' Returns the cell type of the upper left
    > ' cell in a range
    > Application.Volatile
    > Set c = c.Range("A1")
    > Select Case True
    > Case IsEmpty(c): CellType = "Blank"
    > Case Application.IsText(c): CellType = "Text"
    > Case Application.IsLogical(c): CellType = "Logical"
    > Case Application.IsErr(c): CellType = "Error"
    > Case IsDate(c): CellType = "Date"
    > Case InStr(1, c.Text, ":") <> 0: CellType = "Time"
    > Case IsNumeric(c): CellType = "Value"
    > End Select
    > End Function
    >
    > I then enter a formula in a cell in a worksheet as =celltype(a1). The
    > function name does not get capitalized, suggesting that it wasn't located,
    > and the result is #NAME?, suggesting same thing. Something's not plugged
    > in
    > somewhere, but I have no idea what. Help!
    >
    > Thanks,
    > George
    >
    >




  3. #3
    G Lykos
    Guest

    Re: Worksheet VBA function - not recognized

    Thanks, Rowan. Added a module in the workbook, pasted the code there, and
    it works - I'm launched! BTW, the capitalization in the formula didn't
    change, so that behavior is apparently different than standard functions -
    looks like you don't get an indication of the validity of a custom function
    name while entering a formula, only by seeing results or lack of them
    (Office 97). Sound right?


    "Rowan" <[email protected]> wrote in message
    news:[email protected]...
    > There is nothing wrong with the function so it probably has to do with

    where
    > you pasted it.
    >
    > If you place the function in a module and reference it on a worksheet in

    the
    > same workbook then you can just type =celltype(A1). If you place the

    function
    > in a workbook other than the one where you are going to use it then you

    must
    > add the book name to the reference eg =PERSONAL.XLS!celltype(E18)
    >
    > Hope this helps
    > Rowan
    >
    >
    > "G Lykos" wrote:
    >
    > > Greetings! Am trying first experience of creating a VBA function that

    is
    > > called via a cell formula in a worksheet, unsuccessfully so far.
    > >
    > > Steps have been to paste code into a workbook module such as:
    > >
    > > Function CellType(c)
    > > ' Returns the cell type of the upper left
    > > ' cell in a range
    > > Application.Volatile
    > > Set c = c.Range("A1")
    > > Select Case True
    > > Case IsEmpty(c): CellType = "Blank"
    > > Case Application.IsText(c): CellType = "Text"
    > > Case Application.IsLogical(c): CellType = "Logical"
    > > Case Application.IsErr(c): CellType = "Error"
    > > Case IsDate(c): CellType = "Date"
    > > Case InStr(1, c.Text, ":") <> 0: CellType = "Time"
    > > Case IsNumeric(c): CellType = "Value"
    > > End Select
    > > End Function
    > >
    > > I then enter a formula in a cell in a worksheet as =celltype(a1). The
    > > function name does not get capitalized, suggesting that it wasn't

    located,
    > > and the result is #NAME?, suggesting same thing. Something's not

    plugged in
    > > somewhere, but I have no idea what. Help!
    > >
    > > Thanks,
    > > George
    > >
    > >
    > >




  4. #4
    Rowan
    Guest

    Re: Worksheet VBA function - not recognized

    Hi George

    You are right about the capitalization. User defined functions do not have
    all of the features of inbuilt Excel functions eg helpfiles etc

    Regards
    Rowan

    "G Lykos" wrote:

    > Thanks, Rowan. Added a module in the workbook, pasted the code there, and
    > it works - I'm launched! BTW, the capitalization in the formula didn't
    > change, so that behavior is apparently different than standard functions -
    > looks like you don't get an indication of the validity of a custom function
    > name while entering a formula, only by seeing results or lack of them
    > (Office 97). Sound right?
    >
    >
    > "Rowan" <[email protected]> wrote in message
    > news:[email protected]...
    > > There is nothing wrong with the function so it probably has to do with

    > where
    > > you pasted it.
    > >
    > > If you place the function in a module and reference it on a worksheet in

    > the
    > > same workbook then you can just type =celltype(A1). If you place the

    > function
    > > in a workbook other than the one where you are going to use it then you

    > must
    > > add the book name to the reference eg =PERSONAL.XLS!celltype(E18)
    > >
    > > Hope this helps
    > > Rowan
    > >
    > >
    > > "G Lykos" wrote:
    > >
    > > > Greetings! Am trying first experience of creating a VBA function that

    > is
    > > > called via a cell formula in a worksheet, unsuccessfully so far.
    > > >
    > > > Steps have been to paste code into a workbook module such as:
    > > >
    > > > Function CellType(c)
    > > > ' Returns the cell type of the upper left
    > > > ' cell in a range
    > > > Application.Volatile
    > > > Set c = c.Range("A1")
    > > > Select Case True
    > > > Case IsEmpty(c): CellType = "Blank"
    > > > Case Application.IsText(c): CellType = "Text"
    > > > Case Application.IsLogical(c): CellType = "Logical"
    > > > Case Application.IsErr(c): CellType = "Error"
    > > > Case IsDate(c): CellType = "Date"
    > > > Case InStr(1, c.Text, ":") <> 0: CellType = "Time"
    > > > Case IsNumeric(c): CellType = "Value"
    > > > End Select
    > > > End Function
    > > >
    > > > I then enter a formula in a cell in a worksheet as =celltype(a1). The
    > > > function name does not get capitalized, suggesting that it wasn't

    > located,
    > > > and the result is #NAME?, suggesting same thing. Something's not

    > plugged in
    > > > somewhere, but I have no idea what. Help!
    > > >
    > > > Thanks,
    > > > George
    > > >
    > > >
    > > >

    >
    >
    >


  5. #5
    G Lykos
    Guest

    Worksheet VBA function - not recognized

    Greetings! Am trying first experience of creating a VBA function that is
    called via a cell formula in a worksheet, unsuccessfully so far.

    Steps have been to paste code into a workbook module such as:

    Function CellType(c)
    ' Returns the cell type of the upper left
    ' cell in a range
    Application.Volatile
    Set c = c.Range("A1")
    Select Case True
    Case IsEmpty(c): CellType = "Blank"
    Case Application.IsText(c): CellType = "Text"
    Case Application.IsLogical(c): CellType = "Logical"
    Case Application.IsErr(c): CellType = "Error"
    Case IsDate(c): CellType = "Date"
    Case InStr(1, c.Text, ":") <> 0: CellType = "Time"
    Case IsNumeric(c): CellType = "Value"
    End Select
    End Function

    I then enter a formula in a cell in a worksheet as =celltype(a1). The
    function name does not get capitalized, suggesting that it wasn't located,
    and the result is #NAME?, suggesting same thing. Something's not plugged in
    somewhere, but I have no idea what. Help!

    Thanks,
    George



  6. #6
    Rowan
    Guest

    RE: Worksheet VBA function - not recognized

    There is nothing wrong with the function so it probably has to do with where
    you pasted it.

    If you place the function in a module and reference it on a worksheet in the
    same workbook then you can just type =celltype(A1). If you place the function
    in a workbook other than the one where you are going to use it then you must
    add the book name to the reference eg =PERSONAL.XLS!celltype(E18)

    Hope this helps
    Rowan


    "G Lykos" wrote:

    > Greetings! Am trying first experience of creating a VBA function that is
    > called via a cell formula in a worksheet, unsuccessfully so far.
    >
    > Steps have been to paste code into a workbook module such as:
    >
    > Function CellType(c)
    > ' Returns the cell type of the upper left
    > ' cell in a range
    > Application.Volatile
    > Set c = c.Range("A1")
    > Select Case True
    > Case IsEmpty(c): CellType = "Blank"
    > Case Application.IsText(c): CellType = "Text"
    > Case Application.IsLogical(c): CellType = "Logical"
    > Case Application.IsErr(c): CellType = "Error"
    > Case IsDate(c): CellType = "Date"
    > Case InStr(1, c.Text, ":") <> 0: CellType = "Time"
    > Case IsNumeric(c): CellType = "Value"
    > End Select
    > End Function
    >
    > I then enter a formula in a cell in a worksheet as =celltype(a1). The
    > function name does not get capitalized, suggesting that it wasn't located,
    > and the result is #NAME?, suggesting same thing. Something's not plugged in
    > somewhere, but I have no idea what. Help!
    >
    > Thanks,
    > George
    >
    >
    >


  7. #7
    Biff
    Guest

    Re: Worksheet VBA function - not recognized

    Hi!

    You're function does work (tried it) but you probably put it in the wrong
    place.

    Put it in a general module

    ALT + F11 to open the VBE
    CTRL + R to open the Project Explorer

    Find your workbook/project name

    Right click the name and selct Insert>Module

    Paste the code in the window that opens.

    Biff

    "G Lykos" <[email protected]> wrote in message
    news:[email protected]...
    > Greetings! Am trying first experience of creating a VBA function that is
    > called via a cell formula in a worksheet, unsuccessfully so far.
    >
    > Steps have been to paste code into a workbook module such as:
    >
    > Function CellType(c)
    > ' Returns the cell type of the upper left
    > ' cell in a range
    > Application.Volatile
    > Set c = c.Range("A1")
    > Select Case True
    > Case IsEmpty(c): CellType = "Blank"
    > Case Application.IsText(c): CellType = "Text"
    > Case Application.IsLogical(c): CellType = "Logical"
    > Case Application.IsErr(c): CellType = "Error"
    > Case IsDate(c): CellType = "Date"
    > Case InStr(1, c.Text, ":") <> 0: CellType = "Time"
    > Case IsNumeric(c): CellType = "Value"
    > End Select
    > End Function
    >
    > I then enter a formula in a cell in a worksheet as =celltype(a1). The
    > function name does not get capitalized, suggesting that it wasn't located,
    > and the result is #NAME?, suggesting same thing. Something's not plugged
    > in
    > somewhere, but I have no idea what. Help!
    >
    > Thanks,
    > George
    >
    >




  8. #8
    G Lykos
    Guest

    Re: Worksheet VBA function - not recognized

    Thanks, Rowan. Added a module in the workbook, pasted the code there, and
    it works - I'm launched! BTW, the capitalization in the formula didn't
    change, so that behavior is apparently different than standard functions -
    looks like you don't get an indication of the validity of a custom function
    name while entering a formula, only by seeing results or lack of them
    (Office 97). Sound right?


    "Rowan" <[email protected]> wrote in message
    news:[email protected]...
    > There is nothing wrong with the function so it probably has to do with

    where
    > you pasted it.
    >
    > If you place the function in a module and reference it on a worksheet in

    the
    > same workbook then you can just type =celltype(A1). If you place the

    function
    > in a workbook other than the one where you are going to use it then you

    must
    > add the book name to the reference eg =PERSONAL.XLS!celltype(E18)
    >
    > Hope this helps
    > Rowan
    >
    >
    > "G Lykos" wrote:
    >
    > > Greetings! Am trying first experience of creating a VBA function that

    is
    > > called via a cell formula in a worksheet, unsuccessfully so far.
    > >
    > > Steps have been to paste code into a workbook module such as:
    > >
    > > Function CellType(c)
    > > ' Returns the cell type of the upper left
    > > ' cell in a range
    > > Application.Volatile
    > > Set c = c.Range("A1")
    > > Select Case True
    > > Case IsEmpty(c): CellType = "Blank"
    > > Case Application.IsText(c): CellType = "Text"
    > > Case Application.IsLogical(c): CellType = "Logical"
    > > Case Application.IsErr(c): CellType = "Error"
    > > Case IsDate(c): CellType = "Date"
    > > Case InStr(1, c.Text, ":") <> 0: CellType = "Time"
    > > Case IsNumeric(c): CellType = "Value"
    > > End Select
    > > End Function
    > >
    > > I then enter a formula in a cell in a worksheet as =celltype(a1). The
    > > function name does not get capitalized, suggesting that it wasn't

    located,
    > > and the result is #NAME?, suggesting same thing. Something's not

    plugged in
    > > somewhere, but I have no idea what. Help!
    > >
    > > Thanks,
    > > George
    > >
    > >
    > >




  9. #9
    Rowan
    Guest

    Re: Worksheet VBA function - not recognized

    Hi George

    You are right about the capitalization. User defined functions do not have
    all of the features of inbuilt Excel functions eg helpfiles etc

    Regards
    Rowan

    "G Lykos" wrote:

    > Thanks, Rowan. Added a module in the workbook, pasted the code there, and
    > it works - I'm launched! BTW, the capitalization in the formula didn't
    > change, so that behavior is apparently different than standard functions -
    > looks like you don't get an indication of the validity of a custom function
    > name while entering a formula, only by seeing results or lack of them
    > (Office 97). Sound right?
    >
    >
    > "Rowan" <[email protected]> wrote in message
    > news:[email protected]...
    > > There is nothing wrong with the function so it probably has to do with

    > where
    > > you pasted it.
    > >
    > > If you place the function in a module and reference it on a worksheet in

    > the
    > > same workbook then you can just type =celltype(A1). If you place the

    > function
    > > in a workbook other than the one where you are going to use it then you

    > must
    > > add the book name to the reference eg =PERSONAL.XLS!celltype(E18)
    > >
    > > Hope this helps
    > > Rowan
    > >
    > >
    > > "G Lykos" wrote:
    > >
    > > > Greetings! Am trying first experience of creating a VBA function that

    > is
    > > > called via a cell formula in a worksheet, unsuccessfully so far.
    > > >
    > > > Steps have been to paste code into a workbook module such as:
    > > >
    > > > Function CellType(c)
    > > > ' Returns the cell type of the upper left
    > > > ' cell in a range
    > > > Application.Volatile
    > > > Set c = c.Range("A1")
    > > > Select Case True
    > > > Case IsEmpty(c): CellType = "Blank"
    > > > Case Application.IsText(c): CellType = "Text"
    > > > Case Application.IsLogical(c): CellType = "Logical"
    > > > Case Application.IsErr(c): CellType = "Error"
    > > > Case IsDate(c): CellType = "Date"
    > > > Case InStr(1, c.Text, ":") <> 0: CellType = "Time"
    > > > Case IsNumeric(c): CellType = "Value"
    > > > End Select
    > > > End Function
    > > >
    > > > I then enter a formula in a cell in a worksheet as =celltype(a1). The
    > > > function name does not get capitalized, suggesting that it wasn't

    > located,
    > > > and the result is #NAME?, suggesting same thing. Something's not

    > plugged in
    > > > somewhere, but I have no idea what. Help!
    > > >
    > > > Thanks,
    > > > George
    > > >
    > > >
    > > >

    >
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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