+ Reply to Thread
Results 1 to 6 of 6

[SOLVED] How to use this function?

  1. #1
    Á÷À˵ÄË&
    Guest

    [SOLVED] How to use this function?

    I want to know how to use the Application.WorkSheetFunction.Text
    function,especially the second argument it uses.

    Any help?


    --



  2. #2
    JE McGimpsey
    Guest

    Re: How to use this function?

    See the TEXT() function in XL Help.

    It's very similar to the VBA function Format()

    In article <#[email protected]>,
    "流浪的双鱼" <[email protected]> wrote:

    > I want to know how to use the Application.WorkSheetFunction.Text
    > function,especially the second argument it uses.


  3. #3
    Á÷À˵ÄË&
    Guest

    Re: How to use this function?

    The Text() function is different from the
    Application.WorkSheetFunction.Text,so is
    function format().

    --



  4. #4
    Arvi Laanemets
    Guest

    Re: How to use this function?

    Hi

    In VBA exists function Format(), with syntax
    Format(Expression,FormatString,FirstDayOfWeek,FirstWeekOfYear)
    All parameters except 1st one are optional, last 2 parameters will have
    meaning only, when expression returns a date.

    In Excel exists function TEXT(), with syntax
    TEXT(NumericExpression,FormatString)
    The worksheetfunction TEXT() is more limited in use, but in general both
    behave identical in their common area, and both do return a string value.

    In VBA, Application.WorksheetFunction.AnyValidFunction invokes an Excel
    worksheetfunction, which otherwise you usually enter into worksheet cell as
    a part of formula. P.e.:
    TodaysDateString = Application.WorksheetFunction.Text(Date,"dddd,
    dd.mm.yyyy")
    , which really is same as
    TodaysDateString = Format(Date,"dddd, dd.mm.yyyy")

    Btw, in VBA exists functions Date and Now, with syntax
    Date
    Now
    , which are returning current system date (and time).
    An equivalent for those are the worksheetfunctions TODAY() or NOW(), in VBA
    used p.e. as
    Application.WorksheetFunction.Today()
    At same time
    Application.WorksheetFunction.Date(Year,Month,Day)
    is an equivalent for VBA function DateSerial, with syntax
    DateSerial(Year,Month,Day).

    The meaning of this long explanation - don't never forget, that
    worksheetfunctions and VBA functions are 2 different collections.


    --
    Arvi Laanemets
    ( My real mail address: arvil<at>tarkon.ee )


    "流浪的双鱼" <[email protected]> wrote in message
    news:[email protected]...
    > The Text() function is different from the
    > Application.WorkSheetFunction.Text,so is
    > function format().
    >
    > --
    >
    >




  5. #5
    Norman Jones
    Guest

    Re: How to use this function?

    Hi Arvi,

    Using:

    > Application.WorksheetFunction.Today()

    or
    > Application.WorksheetFunction.Date(Year,Month,Day)


    would cause an '"Object doesn't support this property or method" error
    message.

    Not all worksheet functions are available to VBA, particularly not when
    equivalent VBA functions exist.

    ---
    Regards,
    Norman



    "Arvi Laanemets" <[email protected]> wrote in message
    news:[email protected]...
    > Hi
    >
    > In VBA exists function Format(), with syntax
    > Format(Expression,FormatString,FirstDayOfWeek,FirstWeekOfYear)
    > All parameters except 1st one are optional, last 2 parameters will have
    > meaning only, when expression returns a date.
    >
    > In Excel exists function TEXT(), with syntax
    > TEXT(NumericExpression,FormatString)
    > The worksheetfunction TEXT() is more limited in use, but in general both
    > behave identical in their common area, and both do return a string value.
    >
    > In VBA, Application.WorksheetFunction.AnyValidFunction invokes an Excel
    > worksheetfunction, which otherwise you usually enter into worksheet cell
    > as a part of formula. P.e.:
    > TodaysDateString = Application.WorksheetFunction.Text(Date,"dddd,
    > dd.mm.yyyy")
    > , which really is same as
    > TodaysDateString = Format(Date,"dddd, dd.mm.yyyy")
    >
    > Btw, in VBA exists functions Date and Now, with syntax
    > Date
    > Now
    > , which are returning current system date (and time).
    > An equivalent for those are the worksheetfunctions TODAY() or NOW(), in
    > VBA used p.e. as
    > Application.WorksheetFunction.Today()
    > At same time
    > Application.WorksheetFunction.Date(Year,Month,Day)
    > is an equivalent for VBA function DateSerial, with syntax
    > DateSerial(Year,Month,Day).
    >
    > The meaning of this long explanation - don't never forget, that
    > worksheetfunctions and VBA functions are 2 different collections.
    >
    >
    > --
    > Arvi Laanemets
    > ( My real mail address: arvil<at>tarkon.ee )
    >
    >
    > "流浪的双鱼" <[email protected]> wrote in message
    > news:[email protected]...
    >> The Text() function is different from the
    >> Application.WorkSheetFunction.Text,so is
    >> function format().
    >>
    >> --
    >>
    >>

    >
    >




  6. #6
    Mike Middleton
    Guest

    Re: How to use this function?

    rover317 -

    When you use Application.WorkSheetFunction.Text(value,format_text) in VBA,
    you are using Excel's TEXT() worksheet function.

    The Excel Text() worksheet function is identical to using
    Application.WorkSheetFunction.Text() in VBA.

    As JE McGimpsey said, the Text() worksheet function and the VBA Format()
    function are similar; they are not identical; the VBA Format() function has
    more features.

    Here's part of the Help for the Text() worksheet function:

    +++++++++++++++++
    TEXT
    Converts a value to text in a specific number format.
    Syntax
    TEXT(value,format_text)
    Value is a numeric value, a formula that evaluates to a numeric value, or
    a reference to a cell containing a numeric value.
    Format_text is a number format in text form from in the Category box on
    the Number tab in the Format Cells dialog box.
    +++++++++++++++++

    To see some of the possible number formats for the second argument, select a
    cell, and choose Format | Cells | Number | Custom.

    For example, in a worksheet cell, =TEXT(3.3333,"0.0") returns 3.3.

    For more details and examples, search for "guidelines for custom number
    formats" in Excel's Help (not in VBA Help).

    - Mike
    www.mikemiddleton.com

    rover317 wrote: > The Text() function is different from the
    Application.WorkSheetFunction.Text,so is function format(). <

    JE McGimpsey wrote: > See the TEXT() function in XL Help. It's very similar
    to the VBA function Format() <

    rover317 wrote: > I want to know how to use the
    Application.WorkSheetFunction.Text function,especially the second argument
    it uses. <



+ 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