Widen merged columns while selected.

S

Shawnn

I would like to find out how to change the width of a merged cell or column
while it is selected and then return it back when another cell is selected.

This is the code I have no but does not work on merged areas. I am using
the DV dropdown list and can not read the text in the list becuse the cell is
too narrow. I can't widen the cell because it is a state form and has to be
in this format.... I am all ears if you can help.

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")
myWidthSelected = Array(10, 10)
myWidthNormal = Array(1.43, 1.43)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top