ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Help with Macro - Make Dropdown List Temporarily Wider (https://www.excelbanter.com/excel-discussion-misc-queries/140696-help-macro-make-dropdown-list-temporarily-wider.html)

AK9955

Help with Macro - Make Dropdown List Temporarily Wider
 
Sorry I'm not a Programmer, so would appreciate your help with the following
macro I pulled from the contextures.com site (thanks to Bob).

Using below macro I was able to make ONE dropdown list temporarily wider.
Hooray. However, when I tried to make another dropdown list (within same
worksheet) temporarily wider, I was at a loss as to how to edit the code.
Tried & tried and I'm tired! Can someone edit below macro to include ANOTHER
DROPDOWN LIST (i.e. column) so I can figure out how its done.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count 1 Then Exit Sub
If Target.Column = 4 Then
Target.Columns.ColumnWidth = 20
Else
Columns(4).ColumnWidth = 5
End If
End Sub

Thanks so much, Anna.

Gary''s Student

Help with Macro - Make Dropdown List Temporarily Wider
 
The key is the fourth line. The code looks for column #4 (column D ). Lets
say we want the code to work on both column D and column J. Instead of:

If Target.Column = 4 Then

use:

If Target.Column = 4 OR Target.Column = 10 Then


--
Gary''s Student - gsnu200717

AK9955

Help with Macro - Make Dropdown List Temporarily Wider
 
Thanks Gary, I understand what your saying. However, what if I want the
column widths to be different for my lists? I wouldn't use an OR statement,
would I?

"Gary''s Student" wrote:

The key is the fourth line. The code looks for column #4 (column D ). Lets
say we want the code to work on both column D and column J. Instead of:

If Target.Column = 4 Then

use:

If Target.Column = 4 OR Target.Column = 10 Then


--
Gary''s Student - gsnu200717



All times are GMT +1. The time now is 08:35 AM.

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