PDA

View Full Version : Solved: Need to set Cell Formatting



CreganTur
12-16-2008, 07:58 AM
I'm working on a very simple program for an area where I work. Basically I'm adding some leading zeros to some of our account numbers in a report they run often. That being said, I need to change the cell formatting to Text, and I'm not sure how to do it. I have two ideas:

I'm running a For...Each loop to change the value of each cell:
Sub test()
Dim cell As Range
For Each cell In Range("A1:A24")
'Do Stuff Here
Next
End Sub

Is there a method to use on the cell variable to change the format? Or is there something I can use on the range? (I'm going to make it a dynamic range later... I just literally started this :p)

Bob Phillips
12-16-2008, 08:28 AM
Dim cell As Range

For Each cell In Range("A1:A24")

cell.NumberFormat = "@"
cell.Value = Left$("00000000", 8 - Len(cell.Value)) & cell.Value
Next cell