+ Reply to Thread
Results 1 to 3 of 3

Auto-Hide Columns

  1. #1
    Forum Contributor
    Join Date
    12-04-2003
    Location
    Burrton, Kansas USA
    MS-Off Ver
    2003
    Posts
    162

    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!!
    Last edited by Brian Matlack; 08-01-2006 at 11:09 AM.

  2. #2
    paul.robinson@it-tallaght.ie
    Guest

    Re: 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. #3
    Forum Contributor
    Join Date
    12-04-2003
    Location
    Burrton, Kansas USA
    MS-Off Ver
    2003
    Posts
    162
    Thanks Paul!! Works Great!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1