Avatar of Jimbo99999
Jimbo99999
Flag 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

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Nasir Razzaq

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Jimbo99999

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
Norie

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Jimbo99999

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.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23