View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Tom Hutchins Tom Hutchins is offline
external usenet poster
 
Posts: 1,069
Default Resize columns wider for pick list

A column-width setting applies to the entire column. You can't make some
cells wider or narrower than other cells in the same column. You can merge
adjacent cells to simulate a wider column, but there are drawbacks to merged
cells. If more than one of the cells has data before merging, only the first
(topmost, leftmost) cell will retain its data after merging. Merged cells
also interfere with some features (like sorting).

Hope this helps,

Hutch

"Joe M." wrote:

I have some code that widens certain colums when clicked upon so I can see
the pick list entire width but don't need the column to stay that width after
selecting the pick list. The code works correctly, however I don't need it to
apply to the entire column, only to certain cells or a range. The code is
below. What changes would I need for particular cells or a cell range within
a column?
Thanks,
Joe M.

Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim myColumns As Variant
Dim myWidthSelected As Variant
Dim myWidthNormal As Variant
Dim iCtr As Long

myColumns = Array("a", "b", "c", "f")
myWidthSelected = Array(30, 40, 30, 40)
myWidthNormal = Array(21, 26, 21, 4.14)

If Target.Count 1 Then Exit Sub

For iCtr = LBound(myColumns) To UBound(myColumns)
If Intersect(Target, _
Me.Cells(1, myColumns(iCtr)).EntireColumn) Is Nothing Then
Me.Cells(1, myColumns(iCtr)).EntireColumn.ColumnWidth _
= myWidthNormal(iCtr)
Else
Me.Cells(1, myColumns(iCtr)).EntireColumn.ColumnWidth _
= myWidthSelected(iCtr)
End If
Next iCtr

End Sub