So, I have a bunch of columns that need to be replaced with a letter, this is old signed overpunch stuff. So basically what I want to do is replace the letters with numbers and then multiply it by 0.01 for each cell.
So basically, I'll have a column like 1. 0000012C = 00000123 x 0.01 = 2.46 2. 0002927B = 29272 x 0.01 = 585.44 3. 0000245N = -00002455 x 0.01 = -24.55
So the problem I cant figure out is how to make the value in a cell negative. As you can see the values for letters (JKLMNOPQR) are negative, however during the replacement step, excel doesnt know how to make the value negative.
I was wondering is there a step I can add where I can turn the values that are JKLMNOPQR negative first and then continue you with the replace function and the multiplication function. I was thinking an it would search cel for JKLMNOPQR and if it had JKLMNOPQR in the cell it would add a negative value in front of the cell and continue you on.
Thanks in advanced, sorry I am new to this.
Private Function DoReplace(Text As String) As String
Dim ReplacedValue As String
ReplacedValue = Text
ReplacedValue = Replace(ReplacedValue, "A", "1")
ReplacedValue = Replace(ReplacedValue, "B", "2")
ReplacedValue = Replace(ReplacedValue, "C", "3")
ReplacedValue = Replace(ReplacedValue, "D", "4")
ReplacedValue = Replace(ReplacedValue, "E", "5")
ReplacedValue = Replace(ReplacedValue, "F", "6")
ReplacedValue = Replace(ReplacedValue, "G", "7")
ReplacedValue = Replace(ReplacedValue, "H", "8")
ReplacedValue = Replace(ReplacedValue, "I", "9")
ReplacedValue = Replace(ReplacedValue, "{", "0")
ReplacedValue = Replace(ReplacedValue, "}", "-0")
ReplacedValue = Replace(ReplacedValue, "J", "-1")
ReplacedValue = Replace(ReplacedValue, "K", "-2")
ReplacedValue = Replace(ReplacedValue, "L", "-3")
ReplacedValue = Replace(ReplacedValue, "M", "-4")
ReplacedValue = Replace(ReplacedValue, "N", "-5")
ReplacedValue = Replace(ReplacedValue, "O", "-6")
ReplacedValue = Replace(ReplacedValue, "P", "-7")
ReplacedValue = Replace(ReplacedValue, "Q", "-8")
ReplacedValue = Replace(ReplacedValue, "R", "-9")
DoReplace = ReplacedValue
End Function
Private Sub MagicButton_Click()
Dim Text As String, CalculatedValue As Double
For Each cell In Worksheets("Sheet1").Range("A1:Z100").Cells
If cell.Value <> "" Then
Text = DoReplace(cell.Value)
CalculatedValue = Val(Text) * 0.01
Worksheets("Sheet2").Cells(cell.Row, cell.Column).Value = CalculatedValue
End If
Next
End Sub