Macro to convert Data to true values

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,601
Office Version
  1. 2021
Platform
  1. Windows
I have values in Col L-see data below that was imported from a PDF file uusing a program to convert these into Excel

I need a macro that will convert these values into proper values that can be usedc for calculations for eg the value in L16 56.244,40- should be -56,244.40. The value in L21 38.361,00 should read as 38,361.00

Your assistance in this regard will be most appreciated
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Instead of a macro, you could select the whole column and

1) Replace every '.' with nothing (so 56.410,00 becomes 56410,00) then
2) Replace every ',' with a '.' (so 56410,00 becomes 56410.00)

If you want a macro then:
Code:
Sub Convert()
With Range("L:L")
    .Replace what:=".", replacement:=""
    .Replace what:=",", replacement:="."
End With
End Sub
 
Upvote 0
Thanks for the help. The values convert correctly, except the negatives, which is shown with a minus after the value for eg 56254.25-. I need the minus sign to precede the value for eg -56254.25

It would be appreciated if you would add this to your code

Thanks

Howard
 
Upvote 0
I've added the numbers to the first two rows of a sheet and run the macro against them, you might need to tweak this code run blitz a whole column of data

Sub dataconvert()

For x = 1 To 2
MyStr$ = Cells(x, 1)
MyStr$ = Replace(MyStr$, ".", "@")
MyStr$ = Replace(MyStr$, ",", ".")
MyStr$ = Replace(MyStr$, "@", ",")
If InStr(1, MyStr$, "-") Then
MyStr$ = Replace(MyStr$, "-", "")
Cells(x, 1) = MyStr$ * -1
Else
Cells(x, 1) = MyStr$
End If
Next

End Sub
 
Upvote 0
Hi Chris

Thanks for the code, much appreciated

Regards

Howard
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,713
Members
452,939
Latest member
WCrawford

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