Avatar of Jimbo99999
Jimbo99999Flag for United States of America

asked on 

VB.Net - Excel Automation Set Column Width on Headings

Good Day Experts!

Making good progress on my little project and am working on the export to Excel from VB.net.  There really isn't too much data that needs to get pushed across but a formatting issue is troubling me.

I put 8 known column headings in cells 3,1 to 3,8.  Now I need to be able to do the equivalent in code of going to the worksheet and doublicking in between column A and B B and C and so on to get the columns to be as wide as the text that I am putting in 3,1 to 3,8.

How do I do this programatically?

Thanks,
jimbo99999
Visual Basic.NETMicrosoft Excel

Avatar of undefined
Last Comment
Jimbo99999
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Jimbo99999
Jimbo99999
Flag of United States of America image

ASKER

Thanks for responding.  I am having trouble implementing what you have suggested.  

oSheet.Range("A", "H").AutoFit()

I need to get columns A through H as wide as the header text I put in cells 3,1 to 3,8.

I am not sure what the range reference should be.

Thanks,
jimbo99999
SOLUTION
Avatar of Norie
Norie

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Jimbo99999
Jimbo99999
Flag of United States of America image

ASKER

Works great thanks all.  Not only am I achieving the tasks when I post my questions by using your answers, but accumulating all the links are very helpful as well.
Microsoft Excel
Microsoft Excel

Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.

144K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo