Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Problems adjusting column width

Hello all,

Just a quick question does anyone know of a way to programmatically adjust
the column with to ensure that the text within a cell is entirely visible.

I have tried

xlSheet.Columns.ShrinkToFit = true;

but this doesnt seem to work.
I have also tried doing it column by column using a range and a foreach loop
but this has the same result.

foreach (string str in arrCols)
{
xlRange1 = xlSheet.get_Range(str + 1, str + 73);
xlRange1.Columns.ShrinkToFit = true;
}

Ive also tried AutoFit() but again not what I need. This just widens all the
col widths to a standard area thats too large for what I need. I just need
the col width to be wide enough to show all the text and thats it, nothing
longer

Any suggestions??

Cheers,
Sean

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Problems adjusting column width

If we are interested in a given column, say column D:

Columns("D:D").EntireColumn.AutoFit

If we are interested in more than one column, then just loop.
--
Gary''s Student - gsnu200763


"sean_mufc" wrote:

Hello all,

Just a quick question does anyone know of a way to programmatically adjust
the column with to ensure that the text within a cell is entirely visible.

I have tried

xlSheet.Columns.ShrinkToFit = true;

but this doesnt seem to work.
I have also tried doing it column by column using a range and a foreach loop
but this has the same result.

foreach (string str in arrCols)
{
xlRange1 = xlSheet.get_Range(str + 1, str + 73);
xlRange1.Columns.ShrinkToFit = true;
}

Ive also tried AutoFit() but again not what I need. This just widens all the
col widths to a standard area thats too large for what I need. I just need
the col width to be wide enough to show all the text and thats it, nothing
longer

Any suggestions??

Cheers,
Sean

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Problems adjusting column width

We're actually dealing with several ranges. The problem is AutoFit() does
re-size width but its over twice as wide as needed. I'm really looking for
another way to resize (not .ShrinkToFit = true as this doesnt work either).
I've tried resizing using ranges and using either worksheet instances but
they dont work either

"Gary''s Student" wrote:

If we are interested in a given column, say column D:

Columns("D:D").EntireColumn.AutoFit

If we are interested in more than one column, then just loop.
--
Gary''s Student - gsnu200763


"sean_mufc" wrote:

Hello all,

Just a quick question does anyone know of a way to programmatically adjust
the column with to ensure that the text within a cell is entirely visible.

I have tried

xlSheet.Columns.ShrinkToFit = true;

but this doesnt seem to work.
I have also tried doing it column by column using a range and a foreach loop
but this has the same result.

foreach (string str in arrCols)
{
xlRange1 = xlSheet.get_Range(str + 1, str + 73);
xlRange1.Columns.ShrinkToFit = true;
}

Ive also tried AutoFit() but again not what I need. This just widens all the
col widths to a standard area thats too large for what I need. I just need
the col width to be wide enough to show all the text and thats it, nothing
longer

Any suggestions??

Cheers,
Sean



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a macro which takes a column name and width and sets the column width to what it should be Ag Excel Programming 4 September 29th 07 11:29 PM
adjusting column width using keystrokes Lesliec4000 Excel Discussion (Misc queries) 1 May 18th 07 04:07 PM
How to make cell width different than the column width it lies in John Excel Discussion (Misc queries) 2 September 11th 06 10:41 PM
Need help with adjusting width of VBA-created toolbars Mark Reynolds Excel Programming 2 February 11th 04 02:24 AM


All times are GMT +1. The time now is 11:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"