Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Program to make cell a formula

I have several employees who send me there budget numbers that are numbers
hard coded into cell. I need to round all of these numbers to the nearest
one hundred. I have a macro that I found on here that I can run but it only
works if the cell contains a formula. Is there a way that I can make the
hard coded numbers a formula so I can use the Rounding Macro or is there a
was to modify this macro to make it work with hard coded number.


Sub RoundAdd2()
Dim myStr As String
Dim Cel As Range
For Each Cel In Selection
If Cel.HasFormula = True Then
If Not Cel.Formula Like "=ROUND(*" Then
myStr = Right(Cel.Formula, Len(Cel.Formula) - 1)
Cel.Value = "=ROUND(" & myStr & "," & "-2" & ")"
End If
End If
Next
End Sub



Thanks for any suggestions!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Program to make cell a formula

Sub RoundAdd2()
Dim myStr As String
Dim Cel As Range
For Each Cel In Selection
If IsNumeric(Cel.Value) Then
If Cel.Value < "" Then
Cel.Value = Application.Round(Cel.Value, -2)
End If
End If
Next
End Sub


--

HTH

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


"Craig" wrote in message
...
I have several employees who send me there budget numbers that are numbers
hard coded into cell. I need to round all of these numbers to the nearest
one hundred. I have a macro that I found on here that I can run but it

only
works if the cell contains a formula. Is there a way that I can make the
hard coded numbers a formula so I can use the Rounding Macro or is there a
was to modify this macro to make it work with hard coded number.


Sub RoundAdd2()
Dim myStr As String
Dim Cel As Range
For Each Cel In Selection
If Cel.HasFormula = True Then
If Not Cel.Formula Like "=ROUND(*" Then
myStr = Right(Cel.Formula, Len(Cel.Formula) - 1)
Cel.Value = "=ROUND(" & myStr & "," & "-2" & ")"
End If
End If
Next
End Sub



Thanks for any suggestions!




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Program to make cell a formula

Thanks! Exactly what I needed.

Craig


"Bob Phillips" wrote in message
...
Sub RoundAdd2()
Dim myStr As String
Dim Cel As Range
For Each Cel In Selection
If IsNumeric(Cel.Value) Then
If Cel.Value < "" Then
Cel.Value = Application.Round(Cel.Value, -2)
End If
End If
Next
End Sub


--

HTH

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


"Craig" wrote in message
...
I have several employees who send me there budget numbers that are
numbers
hard coded into cell. I need to round all of these numbers to the
nearest
one hundred. I have a macro that I found on here that I can run but it

only
works if the cell contains a formula. Is there a way that I can make the
hard coded numbers a formula so I can use the Rounding Macro or is there
a
was to modify this macro to make it work with hard coded number.


Sub RoundAdd2()
Dim myStr As String
Dim Cel As Range
For Each Cel In Selection
If Cel.HasFormula = True Then
If Not Cel.Formula Like "=ROUND(*" Then
myStr = Right(Cel.Formula, Len(Cel.Formula) - 1)
Cel.Value = "=ROUND(" & myStr & "," & "-2" & ")"
End If
End If
Next
End Sub



Thanks for any suggestions!






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Program to make cell a formula

Hi Craig, if I understand your question, the following modification
to your code should work:

Sub RoundAdd2()
Dim myStr As String
Dim Cel As Range
For Each Cel In Selection
Cel.Value = Application.WorksheetFunction.Round(Cel.Value, -2)
Next
End Sub

HTH--Lonnie M.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Program to make cell a formula

Thanks, Lonnie!


"Lonnie M." wrote in message
oups.com...
Hi Craig, if I understand your question, the following modification
to your code should work:

Sub RoundAdd2()
Dim myStr As String
Dim Cel As Range
For Each Cel In Selection
Cel.Value = Application.WorksheetFunction.Round(Cel.Value, -2)
Next
End Sub

HTH--Lonnie M.





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
Excel GURUs help. (How to make program parse more than 1 forumla within a cell) Idz21 Excel Worksheet Functions 5 January 27th 06 08:50 PM
Make a Workbook into VB Program Woody Excel Programming 3 July 23rd 05 05:57 AM
make my vba/excel program faster Frank Kabel Excel Programming 0 May 18th 04 04:58 PM
make my vba/excel program faster pikus Excel Programming 0 May 18th 04 04:44 PM
make my VBA program faster Neil[_14_] Excel Programming 2 May 18th 04 04:15 PM


All times are GMT +1. The time now is 08:01 AM.

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"