Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 103
Default Remove round function

I have a sheet with numerous ROUND functions. I want them all removed. How
can I do a search/replace to remove them all at once.

For example, I want to replace
=ROUND(A1*B1,1)
with this...
=A1*B1

They all end with ,1)

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,718
Default Remove round function

This is a general purpose Round removing routine. It operates on the
selected range.

Sub DoReplaceRounds()
Dim Cell As Range, RoundStart As Integer
Dim Strg As String, Ptr As Integer
Dim FoundOne As Boolean, Char As String
Dim Level As Integer, CommaPtr As Integer
Dim SrchRg As Range
Dim RemoveParen As Integer
On Error GoTo EndThis
RemoveParen = 1 '0 to keep parens
If Selection.Cells.Count = 1 Then
Set SrchRg = ActiveCell
Else
Set SrchRg = Selection.SpecialCells(xlCellTypeFormulas)
End If
For Each Cell In SrchRg
FoundOne = False
Strg = Cell.Formula
FindNext:
RoundStart = InStr(1, Strg, "round(", vbTextCompare)
If RoundStart 0 Then
Level = 1
For Ptr = RoundStart + 6 To Len(Strg)
Char = Mid(Strg, Ptr, 1)
If Char = "(" Then
Level = Level + 1
ElseIf Char = ")" Then
Level = Level - 1
ElseIf Char = "," Then
If Level = 1 Then CommaPtr = Ptr
End If
If Level = 0 Then Exit For
Next

Strg = Application.Replace(Strg, CommaPtr, Ptr - CommaPtr +
RemoveParen, "")

Strg = Application.Replace(Strg, RoundStart, 5 + RemoveParen,
"")
FoundOne = True
GoTo FindNext ''May have more than 1 Round in the formula
Else
If FoundOne Then Cell.Formula = Strg
End If
Next
EndThis:
End Sub

--
Jim
"Arun" wrote in message
...
I have a sheet with numerous ROUND functions. I want them all removed.
How
can I do a search/replace to remove them all at once.

For example, I want to replace
=ROUND(A1*B1,1)
with this...
=A1*B1

They all end with ,1)

Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 103
Default Remove round function

Awesome!! Thanks.

"Jim Rech" wrote:

This is a general purpose Round removing routine. It operates on the
selected range.

Sub DoReplaceRounds()
Dim Cell As Range, RoundStart As Integer
Dim Strg As String, Ptr As Integer
Dim FoundOne As Boolean, Char As String
Dim Level As Integer, CommaPtr As Integer
Dim SrchRg As Range
Dim RemoveParen As Integer
On Error GoTo EndThis
RemoveParen = 1 '0 to keep parens
If Selection.Cells.Count = 1 Then
Set SrchRg = ActiveCell
Else
Set SrchRg = Selection.SpecialCells(xlCellTypeFormulas)
End If
For Each Cell In SrchRg
FoundOne = False
Strg = Cell.Formula
FindNext:
RoundStart = InStr(1, Strg, "round(", vbTextCompare)
If RoundStart 0 Then
Level = 1
For Ptr = RoundStart + 6 To Len(Strg)
Char = Mid(Strg, Ptr, 1)
If Char = "(" Then
Level = Level + 1
ElseIf Char = ")" Then
Level = Level - 1
ElseIf Char = "," Then
If Level = 1 Then CommaPtr = Ptr
End If
If Level = 0 Then Exit For
Next

Strg = Application.Replace(Strg, CommaPtr, Ptr - CommaPtr +
RemoveParen, "")

Strg = Application.Replace(Strg, RoundStart, 5 + RemoveParen,
"")
FoundOne = True
GoTo FindNext ''May have more than 1 Round in the formula
Else
If FoundOne Then Cell.Formula = Strg
End If
Next
EndThis:
End Sub

--
Jim
"Arun" wrote in message
...
I have a sheet with numerous ROUND functions. I want them all removed.
How
can I do a search/replace to remove them all at once.

For example, I want to replace
=ROUND(A1*B1,1)
with this...
=A1*B1

They all end with ,1)

Thanks in advance.




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
Round Len Function Help [email protected] Excel Worksheet Functions 16 August 25th 06 04:27 AM
How do your remove ROUND function? michelle Excel Worksheet Functions 3 July 28th 06 07:11 PM
how do i set up round function run superman Excel Worksheet Functions 1 October 6th 05 08:13 PM
The ROUND function Louise Excel Worksheet Functions 3 June 23rd 05 02:45 PM
Round Function Pedro Serra Excel Discussion (Misc queries) 4 January 27th 05 06:13 PM


All times are GMT +1. The time now is 10:41 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"