Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto hide/Unhide columns Vespaguy Excel Worksheet Functions 5 August 25th 07 01:08 AM
Auto Hide Columns when... Jase4now Excel Discussion (Misc queries) 0 March 28th 07 07:02 PM
Auto Hide-Unhide Columns with a macro Ed Excel Discussion (Misc queries) 0 March 8th 07 07:57 PM
Auto Hide Columns Phil Osman Excel Discussion (Misc queries) 6 September 13th 06 07:32 PM
Auto Hide Columns & Rows appeng Excel Discussion (Misc queries) 2 March 25th 05 04:43 PM


All times are GMT +1. The time now is 04:52 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"