VB6 - formatting an Excel column
-
How can I change an Excel worksheet column's format in vb6. I can open an Excel app and write to it, but if I write text like "00100" it loses the 0's and becomes "100" because the column format is General. How can I change it to Text in code? :rose::rose: 1fm1fu
-
How can I change an Excel worksheet column's format in vb6. I can open an Excel app and write to it, but if I write text like "00100" it loses the 0's and becomes "100" because the column format is General. How can I change it to Text in code? :rose::rose: 1fm1fu
The quick way to do it is to use "'00100" or write a quick function to append the ' to the front of the value. Or set the numberformat property for the range then the value as below: Dim c As Range Set c = Worksheets("Sheet1").Range("A1") c.NumberFormat = "@" c.Value = "00100"
-
The quick way to do it is to use "'00100" or write a quick function to append the ' to the front of the value. Or set the numberformat property for the range then the value as below: Dim c As Range Set c = Worksheets("Sheet1").Range("A1") c.NumberFormat = "@" c.Value = "00100"
Thanx jonathan15, this works. I'll try hard and convince Christine, my code tester, not to worry about the mark this makes in the cell. :rose::rose: 1fm1fu
-
Thanx jonathan15, this works. I'll try hard and convince Christine, my code tester, not to worry about the mark this makes in the cell. :rose::rose: 1fm1fu
If you use the second method the only mark it will leave will be a green tab in the top left corner of the cell which is simply there to show that it is a number formatted as text. This would be there even if you used the Excel menu to format the cell. Jonathan