Create a macro to format a column [Solved/Closed]

Vivian - Aug 5, 2010 at 12:32 PM - Latest reply:  Vivian
- Aug 20, 2010 at 08:17 AM

I am not a programmer but I know how to create basic macros that would perform simple repeated tasks in a fixed range within a sheet.

Right now I'm encountering a task that would require a tiny bit of programming versus a simple recording of a macro. I happen to find this site . . . I was wondering if someone could help. I am greatful for those who could take their time to resolve this. Many thanks in advance.

Routinely I recieve Excel workbooks from new vendors. Each vendor would have their fields(columns) and formats arranged differently. I'm wondering if some could show me how to create a macro that would format a column that I select.

For example, when I open up a workbook, if I select column C (a date field) and run the macro, the macro would format column C into mm/dd/yy. If I select Column F and run the macro, the macro would format coumn F into mm/dd/yy.

Again - many thanks.

See more 

3 replies

Best answer
Thank you
Place this on a module on VBA Editor

Sub format()
Selection.NumberFormat = "mm-dd-yy"

End Sub

When you want to run the macro, select the column you want to format and then run the macro

Thank you, Bren 1

Something to say? Add comment

CCM has helped 1662 users this month

Hi Bren,

Thank you so much. This is exactly what I'm looking for. I know I could do it menually by clicking the menu bar or do the "text to column" as suggested by rizvisa1. But when there are so many date columns to be formatted in a workbook, the manual task becomes very tedeous. You are a life saver. Thank you again!
rizvisa1 4481 Posts Thursday January 28, 2010Registration dateContributorStatus January 6, 2016 Last seen - Aug 5, 2010 at 12:49 PM
Thank you
If only thing that you want to do is covert the text of columns into date, then you can use the Text to column option available under Data