ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formatting a column - needs refresh? (https://www.excelbanter.com/excel-programming/307874-formatting-column-needs-refresh.html)

James[_24_]

Formatting a column - needs refresh?
 
Hi,
I am exporting stuff out from a vb program to a .csv file, then optionally
opening this in excel for the user to view. One of the columns of
information contains phone numbers, but when excel opens the file it sees it
as a number and shows it wrong. i.e. 447768123456 comes out as 4.47769E+11.
I have put the following line in my code:

.Columns(2).Select
.Selection.NumberFormat = "@"

which works, except for the cell to refresh to look correct I need to click
on the (correctly displayed) number in the formula bar at the top of the
screen, at which point the number displayed in the cell appears correctly.
How can I automate this step?
Thanks,
James.



E_R[_25_]

Formatting a column - needs refresh?
 
Try this instead...

Columns(2).Select
Selection.NumberFormat = "#

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Formatting a column - needs refresh?
 
with Columns(2)
.NumberFormat = "000000000000"
.Autofit
End With

--
Regards,
Tom Ogilvy
"James" wrote in message
...
Hi,
I am exporting stuff out from a vb program to a .csv file, then optionally
opening this in excel for the user to view. One of the columns of
information contains phone numbers, but when excel opens the file it sees

it
as a number and shows it wrong. i.e. 447768123456 comes out as

4.47769E+11.
I have put the following line in my code:

.Columns(2).Select
.Selection.NumberFormat = "@"

which works, except for the cell to refresh to look correct I need to

click
on the (correctly displayed) number in the formula bar at the top of the
screen, at which point the number displayed in the cell appears correctly.
How can I automate this step?
Thanks,
James.





James[_24_]

Formatting a column - needs refresh?
 

"Tom Ogilvy" wrote in message
...
with Columns(2)
.NumberFormat = "000000000000"
.Autofit
End With


Thanks for the help folks, all working now!




All times are GMT +1. The time now is 12:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com