Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Ganvenk
 
Posts: n/a
Default 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   Report Post  
Bob Umlas
 
Posts: n/a
Default

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" wrote in message
...
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   Report Post  
Dave Peterson
 
Posts: n/a
Default

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function Macro for Nested IF Qaspec Excel Worksheet Functions 5 March 10th 05 07:25 PM
help with round function Scott Excel Worksheet Functions 7 February 9th 05 07:23 PM
PivotTable Macro Reverts to Count Function LTofsrud Excel Worksheet Functions 4 February 8th 05 09:41 PM
How can I embed a macro into a function in excel? Don Excel Worksheet Functions 2 January 28th 05 01:30 AM
Round Function Pedro Serra Excel Discussion (Misc queries) 4 January 27th 05 06:13 PM


All times are GMT +1. The time now is 04:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"