PDA

View Full Version : Solved: How to format columns on 'Workbook Open'



thomas.szwed
08-07-2008, 03:17 AM
hi there,

could anyone tell me some VB to do the following automatically when the workbook is opened.

In Workbook on ALL sheets

Format all cells in columns E F and J into 'Text' format.

I have this so far but unsure how to modify

With ThisWorkbook.Worksheets(1)
.Columns("J").NumberFormat = "dd/mm/yyyy"
End With

Thanks in advance!

Bob Phillips
08-07-2008, 03:33 AM
Private Sub Workbook_Open()
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets

ws.Columns("E:F").NumberFormat = "@"
ws.Columns("J").NumberFormat = "@"
Next ws
End Sub

thomas.szwed
08-07-2008, 03:36 AM
Thanks XLD but is this text format?

Bob Phillips
08-07-2008, 04:03 AM
Yes it is.

thomas.szwed
08-07-2008, 04:05 AM
taa