ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If statement in VBA to change formatting from % to numbers (https://www.excelbanter.com/excel-programming/421849-if-statement-vba-change-formatting-%25-numbers.html)

Crauwf

If statement in VBA to change formatting from % to numbers
 
I have column in a s/s where some numbers are currently formatted as a
percentage and others as a number, but i want to change them so that they are
formatted as numbers.

So for example in a column i have:-

A B (What i want it to return)
65% 65
63% 63
62 62
61% 61

I tried writing the below code, but VBA didn't like it....

Sub Macro2()

x = 1

Do Until Cells(x, 8).Value = ""

Cells(x, 8).Select

If Cells(x, 8).Format = "0.00%" Then

Selection.NumberFormat = "0.00"


End If

x = x + 1

Loop

End Sub

I realise that i would have to add a column and * all %'s by a hundred to
get my desired effect.

Could anyone help with my query.

Thanks! Crauwf.

Crauwf

If statement in VBA to change formatting from % to numbers
 
Worked it out... sorry for anyone who looked at it!


"Crauwf" wrote:

I have column in a s/s where some numbers are currently formatted as a
percentage and others as a number, but i want to change them so that they are
formatted as numbers.

So for example in a column i have:-

A B (What i want it to return)
65% 65
63% 63
62 62
61% 61

I tried writing the below code, but VBA didn't like it....

Sub Macro2()

x = 1

Do Until Cells(x, 8).Value = ""

Cells(x, 8).Select

If Cells(x, 8).Format = "0.00%" Then

Selection.NumberFormat = "0.00"


End If

x = x + 1

Loop

End Sub

I realise that i would have to add a column and * all %'s by a hundred to
get my desired effect.

Could anyone help with my query.

Thanks! Crauwf.



All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com