Link to home
Start Free TrialLog in
Avatar of btkrausen
btkrausen

asked on

Excel Macro to Change Column Format to Number?

I'm having a terrible time with what I think should be a very simple macro.  I need to select columns E and F and change their format to Number.

Here is what I have currently:
Sub EF_to_Number()
'
' EF_to_Number Macro
'
'
    Range("E:E,F:F").Select
    Selection.NumberFormat = "0.00"
End Sub

Open in new window

When you run this macro it changes ALL columns to number format - not just E and F.

I've also tried selecting just one column or the other and the same problem occurs.  What am I missing?

For what it's worth, I'm using Excel 2013.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Glenn Ray
Glenn Ray
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Montoya
Montoya

Since you're only doing two columns:

Worksheets("Sheet1").Columns(5).NumberFormat = "0.00"  // Where 5 is the alphabet position of the column
Worksheets("Sheet1").Columns(6).NumberFormat = "0.00"

That would do column e and f
I didnt type fast enough.. ;)
Avatar of btkrausen

ASKER

That worked perfectly!  Thanks.