![]() |
VBA Change Format of All Cells in a Workbook
With VBA I would like to change the format of all cells in all
worksheets of a workbook to 'General' or 'Text'. How can this be done? Thanks. |
VBA Change Format of All Cells in a Workbook
One way:
Dim ws As Worksheet For Each ws in ActiveWorkbook.Worksheets ws.Cells.NumberFormat = "General" ' or "@" for Text Next ws In article , wrote: With VBA I would like to change the format of all cells in all worksheets of a workbook to 'General' or 'Text'. How can this be done? Thanks. |
VBA Change Format of All Cells in a Workbook
Sub test()
For Each sht In Sheets sht.Cells.NumberFormat = "General" Next sht End Sub or Sub test() For Each sht In Sheets sht.Cells.NumberFormat = "@" 'for text Next sht End Sub " wrote: With VBA I would like to change the format of all cells in all worksheets of a workbook to 'General' or 'Text'. How can this be done? Thanks. |
VBA Change Format of All Cells in a Workbook
This should do it
Sub ChangeWorkbookFormat() Dim WS As Worksheet For Each WS In Worksheets WS.Range("1:" & WS.Rows.Count).NumberFormat = "General" Next End Sub Use "@" instead of "General" if you want the Text format. -- Rick (MVP - Excel) wrote in message ... With VBA I would like to change the format of all cells in all worksheets of a workbook to 'General' or 'Text'. How can this be done? Thanks. |
VBA Change Format of All Cells in a Workbook
As others have pointed out, Cells is better to use than my
Range("1:"&WS.Rows.Count). -- Rick (MVP - Excel) "Rick Rothstein" wrote in message ... This should do it Sub ChangeWorkbookFormat() Dim WS As Worksheet For Each WS In Worksheets WS.Range("1:" & WS.Rows.Count).NumberFormat = "General" Next End Sub Use "@" instead of "General" if you want the Text format. -- Rick (MVP - Excel) wrote in message ... With VBA I would like to change the format of all cells in all worksheets of a workbook to 'General' or 'Text'. How can this be done? Thanks. |
All times are GMT +1. The time now is 01:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com