Remove Dr Cr from numbers

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
Hello guys
I have received a data sheet from one of my clients. The problem is I am not able to change the format of the figures and remove Dr & Cr. I require +ve and -ve numbers to finish my work. How is it possible to convert the custom format to number format. I tried selecting the whole column and selecting number format from the menu bar. But it is showing even the negative numbers as positive. Dr is a negative number and Cr is a positive number.
Query to remove Dr Cr from amount.xlsx
A
1Round Off
20.50 Cr
3
40.02 Dr
50.02 Cr
6
70.22 Dr
80.25 Dr
90.03 Dr
10
110.02 Cr
12
130.50 Cr
140.66 Cr
150.46 Dr
160.21 Dr
170.39 Dr
180.42 Dr
190.01 Dr
200.02 Dr
210.01 Cr
220.03 Cr
23
Sheet1
 
Something like this but must be run on a copy of the workbook to test!!

VBA Code:
Sub Macro2()

Dim c As Range, lr As Long, lc As Long

With ActiveSheet
    lr = .Cells.Find(What:="*", After:=.Range("A1"), LookAt:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row
    lc = .Cells.Find(What:="*", After:=.Range("A1"), LookAt:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False).Column
    For Each c In .Range(.Cells(1, 1), .Cells(lr, lc))
        If c.NumberFormat = """""0.00"" Dr""" Then
            If IsNumeric(c) Then
                c.Value = c.Value * -1
            End If
        End If
        c.NumberFormat = "General"
    Next
End With

End Sub
Wow!! That really worked. Thanks Steve. You just saved me a lot of time.
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
One thing i would say is keep a copy of the workbook before you ever run this. You are in a right mess if it should fail halfway through for whatever reason.
 
Upvote 0
One thing i would say is keep a copy of the workbook before you ever run this. You are in a right mess if it should fail halfway through for whatever reason.
Yeah. I always do that. Thanks once again.
 
Upvote 0

Forum statistics

Threads
1,224,591
Messages
6,179,768
Members
452,940
Latest member
rootytrip

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