Rounding macro

linesy

Board Regular
Joined
Sep 27, 2004
Messages
72
Hi all,

I have a worksheet that pulls in data from another source that has 7+ decimal places so when I summarize the data I have balancing issues with the rounding.

Does anyone have a macro that will take the data in cells D34:E49, G34:HE49, J34:K49, M34:N49, round and absolute the numbers to 1 decimale place?

Thanks so much in advance :)
 
Try this on a copy of your workbook:

Code:
Set x = Range("D34:E49,G34:H49,J34:K49,M34:N49")
For Each c In x.Areas
    c.Value = Evaluate("=IFERROR(IF(LEN(" & c.Address & ")>0,ROUND(" & c.Address & ",1),"""")," & c.Address & ")")
Next
 
Upvote 0
Try this:
Code:
Sub MyMacro()


    Dim myRange As Range
    Dim cell As Range
        
    Application.ScreenUpdating = False
            
    Set myRange = Range("D34:E49, G34:H39, J34:K49, M34:N49")
    
    For Each cell In myRange
        cell = Round(Abs(cell), 1)
    Next cell
    
    Application.ScreenUpdating = True
    
End Sub
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top