Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Column Width for Each Column

Hi Guys;
I have the code below working but I need to adjust the Column
Width for Each Column Seperately! Only my second time with Excel, so please
excuse my lack of experience!

With ws.Range("A:Q").EntireColumn
.ColumnWidth = 100
.AutoFit
End With

Example Column A = 25
Column B = 75
Column C = 14
etc.

How do I do this in Macro Code?

Thank You in Advance Group!

Nancy X
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Column Width for Each Column

set up an array of columnwidths:

Dim myColWidths as variant
dim iCol as long
'just 3 columns for my test
mycolwidths = array(25, 75, 14)

for icol = lbound(mycolwidths) to ubound(mycolwidths)
'same as for icol = 0 to 2
with ws.columns(icol+1)
.columnwidth = 100
.autofit
end with
next icol




Nancy X wrote:

Hi Guys;
I have the code below working but I need to adjust the Column
Width for Each Column Seperately! Only my second time with Excel, so please
excuse my lack of experience!

With ws.Range("A:Q").EntireColumn
.ColumnWidth = 100
.AutoFit
End With

Example Column A = 25
Column B = 75
Column C = 14
etc.

How do I do this in Macro Code?

Thank You in Advance Group!

Nancy X


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Column Width for Each Column


Sub MakeThemFitBetter()
Dim vSizes As Variant
Dim N As Long
'one number for each column width
vSizes = Array(25, 75, 14, 19, 21, 23) 'need 17 numbers...
For N = 1 To 17
ws.Columns(N).Width = vSizes(N - 1)
Next
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware




(Excel Add-ins / Excel Programming)
"Nancy X"
wrote in message
Hi Guys;
I have the code below working but I need to adjust the Column
Width for Each Column Seperately! Only my second time with Excel, so please
excuse my lack of experience!

With ws.Range("A:Q").EntireColumn
.ColumnWidth = 100
.AutoFit
End With

Example Column A = 25
Column B = 75
Column C = 14
etc.

How do I do this in Macro Code?

Thank You in Advance Group!

Nancy X
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Column Width for Each Column


ws.Columns(N).Width = vSizes(N - 1)
should read...
Columns(N).ColumnWidth = vSizes(N - 1)
--
Jim Cone


"Jim Cone"

wrote in message
Sub MakeThemFitBetter()
Dim vSizes As Variant
Dim N As Long
'one number for each column width
vSizes = Array(25, 75, 14, 19, 21, 23) 'need 17 numbers...
For N = 1 To 17
ws.Columns(N).Width = vSizes(N - 1)
Next
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)

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
how do I create multiple column width in the same column in excel Vish Excel Discussion (Misc queries) 9 November 3rd 06 11:49 PM
Setting column width if #### appears in column qwerty[_2_] Excel Programming 14 April 9th 06 04:05 PM
Varying column width in a column chart Silvie Dedkova Charts and Charting in Excel 1 March 22nd 05 01:53 PM
Change the width of a single column in a column chart Dave Charts and Charting in Excel 2 December 13th 04 07:25 PM


All times are GMT +1. The time now is 06:31 AM.

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

About Us

"It's about Microsoft Excel"