Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do I create multiple column width in the same column in excel | Excel Discussion (Misc queries) | |||
Setting column width if #### appears in column | Excel Programming | |||
Varying column width in a column chart | Charts and Charting in Excel | |||
Change the width of a single column in a column chart | Charts and Charting in Excel |