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
 
Just highlight all the cells with button top left of sheet then right click, format cells, change it to general or number.
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Just highlight all the cells with button top left of sheet then right click, format cells, change it to general or number.
That is what I did in the first instance. As I said all the amounts display positive numbers only. Hence, the round off and all other columns won't match. At least if I could sort the data with dr and cr amounts it would be easier to work. But that too doesn't work.
 
Upvote 0
Oh. You are in a little trouble then. You have different formats randomly around the worksheet but the actual underlying numbers are all positive. If you click a positive number the format is the Cr one but im assuming the Dr ones have the other format. You are going to need to use code to fix that. It isnt possible otherwise unless you go through them one by one.
 
Upvote 0
N.B. You specified Dr is a negative number and Cr is a positive number

2 approaches to consider
You can use a temporary column; Insert a column
Enter the formula depending on whether of not the custom formatting shows Dr or Cr.
Copy the formula down to the relevant cells for Dr
Copy the formula down to the relevant cells for Cr
Format the cells as numbers
Convert the column to values
Check that the numbers are correct and then delete column A

or you copy a cell that contain -1 and Paste Special multiply to the relevant cells

T202106a.xlsm
AB
1Round Off
20.50Cr0.50
30.02 Dr-0.02
6c
Cell Formulas
RangeFormula
B2B2=A2
B3B3=-A3
 
Upvote 0
Im not sure thats much help Dave. May as well just type them. They are randomly assigned different formats all over the worksheet from what i can tell.
 
Upvote 0
Steve I didn't see the post 10.

I don't have a suggestion based on the information provided.

If the data is a financial report, it should balance and the Dr or Cr formatting may be irrelevant.
 
Upvote 0
From what i can tell all of the numbers are positive but have different formatting randomly, one changing them to Cr the other Dr. Would have to be vba i think.
 
Upvote 0
From what i can tell all of the numbers are positive but have different formatting randomly, one changing them to Cr the other Dr. Would have to be vba i think.
Actually , This is a sheet exported in excel format from another software where the amounts are shown in Dr and Cr instead of -ve and +ve figures. I am just trying to figure out how to replace the Dr amounts with negative numbers and Cr amounts with positive numbers.
 
Upvote 0
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
 
Upvote 0
Solution
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
Yes Steve. That worked in the query sheet. Let me try and check in the original data.
 
Upvote 0

Forum statistics

Threads
1,216,119
Messages
6,128,947
Members
449,480
Latest member
yesitisasport

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