ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Widen merged columns while selected. (https://www.excelbanter.com/excel-discussion-misc-queries/213381-widen-merged-columns-while-selected.html)

Shawnn

Widen merged columns while selected.
 
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


All times are GMT +1. The time now is 12:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com