How can i change the cell format in a range using a macro?

A

Alvaro G?lvez

Hi:

I need to change the cell format in a specific range using a macro.
I insert into this range a lot of values and excel change the cell
format automatic, changing it from General to numeric or something
else. I need this range always behave as text. Is there anything like
Worksheets(xxx).range(x, y).type = text ??

Thanks! :)
 
G

Gord Dibben

Sub TextFormat()
Selection.NumberFormat = "@"
End Sub

Or in Workbook_Open

WorkSheets("Sheet1").Range("A1:H34").NumberFormat = "@"

Gord Dibben Excel MVP
 
Top