+ Reply to Thread
Results 1 to 3 of 3

using a macro round function

  1. #1
    Ganvenk
    Guest

    using a macro round function

    I would like to create a shortcut for using ‘round’ function ( ctr + r ) in
    the following manner:

    A1 = 255.87 ; B1 = 45678.8974 ; C1 = +d5*25
    If I apply Ctr + r on A1 it should become @round(255.87,0)
    If I apply Ctr + r on B1 it should become @round(45678.8974,0)
    If I apply Ctr + r on C1 it should become @round(+d5*25,0)

    In lotus I used to use this as a macro on the following logic:
    Go to cell
    Apply ‘ctr+r’
    The macro will do the following:
    F2 (edit)
    Home
    Type @round(
    End
    Type ,0)
    Enter

    The same is not working in Excel. Can someone clarify or suggest
    Thanks


  2. #2
    Bob Umlas
    Guest

    Re: using a macro round function

    This should do the trick:

    Sub DoRound()
    For Each oCell In Selection
    oCell.Formula = "=ROUND(" & oCell.Formula & ",0)"
    Next
    End Sub


    Bob Umlas
    Excel MVP

    "Ganvenk" <[email protected]> wrote in message
    news:[email protected]...
    > I would like to create a shortcut for using 'round' function ( ctr + r )

    in
    > the following manner:
    >
    > A1 = 255.87 ; B1 = 45678.8974 ; C1 = +d5*25
    > If I apply Ctr + r on A1 it should become @round(255.87,0)
    > If I apply Ctr + r on B1 it should become @round(45678.8974,0)
    > If I apply Ctr + r on C1 it should become @round(+d5*25,0)
    >
    > In lotus I used to use this as a macro on the following logic:
    > Go to cell
    > Apply 'ctr+r'
    > The macro will do the following:
    > F2 (edit)
    > Home
    > Type @round(
    > End
    > Type ,0)
    > Enter
    >
    > The same is not working in Excel. Can someone clarify or suggest
    > Thanks
    >




  3. #3
    Dave Peterson
    Guest

    Re: using a macro round function

    I don't think Bob saw the formula in C1:

    Option Explicit
    Sub DoRound2()
    Dim oCell As Range
    For Each oCell In Selection
    If oCell.HasFormula Then
    oCell.Formula = "=round(" & Mid(oCell.Formula, 2) & ",0)"
    Else
    oCell.Formula = "=ROUND(" & oCell.Formula & ",0)"
    End If
    Next
    End Sub


    Ganvenk wrote:
    >
    > I would like to create a shortcut for using ‘round’ function ( ctr + r ) in
    > the following manner:
    >
    > A1 = 255.87 ; B1 = 45678.8974 ; C1 = +d5*25
    > If I apply Ctr + r on A1 it should become @round(255.87,0)
    > If I apply Ctr + r on B1 it should become @round(45678.8974,0)
    > If I apply Ctr + r on C1 it should become @round(+d5*25,0)
    >
    > In lotus I used to use this as a macro on the following logic:
    > Go to cell
    > Apply ‘ctr+r’
    > The macro will do the following:
    > F2 (edit)
    > Home
    > Type @round(
    > End
    > Type ,0)
    > Enter
    >
    > The same is not working in Excel. Can someone clarify or suggest
    > Thanks


    --

    Dave Peterson

+ 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