+ Reply to Thread
Results 1 to 6 of 6

VBA code to edit a formula in excel?

  1. #1

    VBA code to edit a formula in excel?

    I am trying to come up with some code that would take a formula and
    edit to put in the ROUND function to round the result to 2 places.

    Thank you for any ideas.


  2. #2
    JE McGimpsey
    Guest

    Re: VBA code to edit a formula in excel?

    Take a look at this article in the archives:

    http://groups.google.com/group/micro...browse_thread/
    thread/a1c45338385e0fff/0afe4bc0c46218c8

    In article <[email protected]>,
    [email protected] wrote:

    > I am trying to come up with some code that would take a formula and
    > edit to put in the ROUND function to round the result to 2 places.
    >
    > Thank you for any ideas.


  3. #3
    Bob Phillips
    Guest

    Re: VBA code to edit a formula in excel?

    If having problems, try http://tinyurl.com/cxupr

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "JE McGimpsey" <[email protected]> wrote in message
    news:[email protected]...
    > Take a look at this article in the archives:
    >
    > http://groups.google.com/group/micro...browse_thread/
    > thread/a1c45338385e0fff/0afe4bc0c46218c8
    >
    > In article <[email protected]>,
    > [email protected] wrote:
    >
    > > I am trying to come up with some code that would take a formula and
    > > edit to put in the ROUND function to round the result to 2 places.
    > >
    > > Thank you for any ideas.




  4. #4
    Gary Keramidas
    Guest

    Re: VBA code to edit a formula in excel?

    Range("b1").Formula = "=round(" & Range("A1").Value & ",2)"

    would take the value of a1 and round it to 2 places and put the result in b1

    --


    Gary


    <[email protected]> wrote in message
    news:[email protected]...
    >I am trying to come up with some code that would take a formula and
    > edit to put in the ROUND function to round the result to 2 places.
    >
    > Thank you for any ideas.
    >




  5. #5

    Re: VBA code to edit a formula in excel?

    Thanks Gary, it works on one enty, is there a way I can apply it to a
    range of highlighted cells?

    I tried the other reference given but I couldn't make it work.

    Thanks


  6. #6
    Gary Keramidas
    Guest

    Re: VBA code to edit a formula in excel?

    see if this works for you

    Option Explicit
    Dim cell As Range
    Sub RoundNumbers()
    For Each cell In Selection
    cell.Formula = "=round(" & cell.Value & ",2)"
    Next
    End Sub

    --


    Gary


    <[email protected]> wrote in message
    news:[email protected]...
    > Thanks Gary, it works on one enty, is there a way I can apply it to a
    > range of highlighted cells?
    >
    > I tried the other reference given but I couldn't make it work.
    >
    > Thanks
    >




+ 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