Saturday, 1 April 2023

Changing Dr / Cr of Tally to +/-

Write the following code in VBA

Select a Range of cells and excute to convert into +/-


Sub ConvertDRCRofTallyData()

Dim rng As Range
Set rng = Selection

For Each cell In rng
   
        If InStr(1, cell.NumberFormat, "Dr") > 0 Then
        cell.Value = cell.Value * -1
        Else
        cell.Value = cell.Value
        End If
       
        cell.NumberFormat = "General"
   
Next

MsgBox "Done"

End Sub


No comments:

Post a Comment