Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to set excel column width from VB 1

Status
Not open for further replies.

cassidybklyn

Programmer
Apr 23, 2007
82
US
Gentlemen,
I am using Visual basic 6.0 to import data from access table to excel spreadsheet. The process wss successful, but one of the fields in the spreadsheet is a date field but it does not display the date, rather it displays "#######". when I go into the spreadsheet and manually widen the column that has the date, the dates displays correctly. How can I set the column width from VB so that the date field displays correctly?
Thanks.
C.
 
In VBA, try this:

Columns("C").Select
Columns("C").EntireColumn.AutoFit

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 



Code:
SheetObject.UsedRange.EntireColumn.AutoFit
autofits ALL columns




Skip,

[glasses] [red][/red]
[tongue]
 
Thanks Skip.
You've a tremendous help. I wish I can buy you a "drink" somehow.
C.
 
Actually you can buy him a drink:


New website, starting in NYC, to be expanding around the globe. disclaimer: I have no financial interest in this company.

Software Sales, Training, Implementation and Support for Macola, eSynergy, and Crystal Reports

"If you have a big enough dictionary, just about everything is a word"
--Dave Barry
 




My drink of choice is [highlight orange]Diet Peach Snapple[/highlight]. ;-)

Skip,

[glasses] [red][/red]
[tongue]
 
Skip,
ha ha ha ha ha :)
Okay, "Diet Peach Snapple" - u got it. Didnt know the "best stuff on earth" comes in diet flavor.
Thanks.
C.
 




You wouldn't want me to get all hyper on sugar, would you?

Skip,

[glasses] [red][/red]
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top