Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Auto-Hide Columns
Hi! I want to automatically hide columns on a sheet based on the users selection of a start date and end date. The user selects a date from a data validation dropdown list and then a vlookup formula puts the corrisponding column letter in cells B3 and C3 of the sheet named "Hide Columns" This is what I have but it keeps giving me an error "Type Mismatch". <start code Private Sub Worksheet_Change(ByVal Target As Excel.Range) Dim choice1 As String Dim choice2 As String choice1 = Worksheets("Hide Columns").Cells(3, 2) choice2 = Worksheets("Hide Columns").Cells(3, 3) On Error GoTo ErrHandler If choice1 = "" Or choice2 = "" Then End Else Columns("choice1:choice2").Select Selection.EntireColumn.Hidden = True Range("A1").Select End If ErrHandler: End Sub <end code Any help would be greatly appreciated. Thanks for your time!! -- Brian Matlack ------------------------------------------------------------------------ Brian Matlack's Profile: http://www.excelforum.com/member.php...fo&userid=3508 View this thread: http://www.excelforum.com/showthread...hreadid=567066 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Auto-Hide Columns
Hi
Change the text: ("choice1:choice2") to (choice1 & ":" & choice2) choice1 and choice2 are already strings, so you need to create the right text string using them. regards Paul Brian Matlack wrote: Hi! I want to automatically hide columns on a sheet based on the users selection of a start date and end date. The user selects a date from a data validation dropdown list and then a vlookup formula puts the corrisponding column letter in cells B3 and C3 of the sheet named "Hide Columns" This is what I have but it keeps giving me an error "Type Mismatch". <start code Private Sub Worksheet_Change(ByVal Target As Excel.Range) Dim choice1 As String Dim choice2 As String choice1 = Worksheets("Hide Columns").Cells(3, 2) choice2 = Worksheets("Hide Columns").Cells(3, 3) On Error GoTo ErrHandler If choice1 = "" Or choice2 = "" Then End Else Columns("choice1:choice2").Select Selection.EntireColumn.Hidden = True Range("A1").Select End If ErrHandler: End Sub <end code Any help would be greatly appreciated. Thanks for your time!! -- Brian Matlack ------------------------------------------------------------------------ Brian Matlack's Profile: http://www.excelforum.com/member.php...fo&userid=3508 View this thread: http://www.excelforum.com/showthread...hreadid=567066 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Auto-Hide Columns
Thanks Paul!! Works Great!! -- Brian Matlack ------------------------------------------------------------------------ Brian Matlack's Profile: http://www.excelforum.com/member.php...fo&userid=3508 View this thread: http://www.excelforum.com/showthread...hreadid=567066 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Auto hide/Unhide columns | Excel Worksheet Functions | |||
Auto Hide Columns when... | Excel Discussion (Misc queries) | |||
Auto Hide-Unhide Columns with a macro | Excel Discussion (Misc queries) | |||
Auto Hide Columns | Excel Discussion (Misc queries) | |||
Auto Hide Columns & Rows | Excel Discussion (Misc queries) |