Consulting

Results 1 to 5 of 5

Thread: Solved: Filter and VBA

  1. #1
    VBAX Newbie
    Joined
    Jul 2011
    Posts
    3
    Location

    Unhappy Solved: Filter and VBA

    Hi everyone,
    I am a newbie here. I am familiar with excel but have problems with marco…… all your helps and supports will be greatly appreciated!!
    Would you please take a look at the spreadsheet I attached? As it demonstrates we have two groups – Group Scott needs to complete tasks A to G and Group Kevin should finish tasks H to K. The table also shows the steps and processes in details.
    I want to insert a filer or button in cell A1 or somewhere else in the sheet. When I select or enter “Task A” in it, only the details for the process of Task A show up. Could you please give me your opinion or suggestion re how to do that?
    Thanks very much for your help in advance!!!
    Dais
    Attached Files Attached Files

  2. #2
    VBAX Expert CatDaddy's Avatar
    Joined
    Jun 2011
    Posts
    581
    Location
    [VBA]Sub HideOtherTasks()
    Dim curTask As String
    Dim curCol As Long
    Dim cell As Range
    ActiveWorkbook.Sheets(1).Activate
    Range("A1").Activate
    curTask = "Task " & InputBox("Task: ", , "A")
    For Each cell In Range("C2:M2")
    If cell.Text = curTask Then
    curCol = cell.Column
    Else
    cell.EntireColumn.Hidden = True
    End If
    Next cell
    End Sub[/VBA]
    ------------------------------------------------
    Happy Coding my friends

  3. #3
    VBAX Newbie
    Joined
    Jul 2011
    Posts
    3
    Location
    Thanks so much, CatDaddy!! You're awesome!!!

    Only two more questions:
    1. what should I do if I need to change the task names? For example, I changed them to Jan, Feb, March, April, May, etc and wanted to get the results by entering the names.

    After I updated that form, I tried to change the code to
    curTask = "Task " & InputBox("Task: ", , "Jan")

    But it doesn't work well.

    2. The other question is: how to be back to the whole table after the individual task searching is done?

    Thanks so much again!!!!

    Quote Originally Posted by CatDaddy
    [vba]Sub HideOtherTasks()
    Dim curTask As String
    Dim curCol As Long
    Dim cell As Range
    ActiveWorkbook.Sheets(1).Activate
    Range("A1").Activate
    curTask = "Task " & InputBox("Task: ", , "A")
    For Each cell In Range("C2:M2")
    If cell.Text = curTask Then
    curCol = cell.Column
    Else
    cell.EntireColumn.Hidden = True
    End If
    Next cell
    End Sub[/vba]

  4. #4
    VBAX Expert CatDaddy's Avatar
    Joined
    Jun 2011
    Posts
    581
    Location
    Quote Originally Posted by Dais
    Thanks so much, CatDaddy!! You're awesome!!!

    Only two more questions:
    1. what should I do if I need to change the task names? For example, I changed them to Jan, Feb, March, April, May, etc and wanted to get the results by entering the names.

    After I updated that form, I tried to change the code to
    curTask = "Task " & InputBox("Task: ", , "Jan")

    But it doesn't work well.

    2. The other question is: how to be back to the whole table after the individual task searching is done?

    Thanks so much again!!!!
    1. The syntax around choosing the task is based on how it looked in your spreadsheet curTask contains "Task" " " and "A" as it stands because the column headers are named "Task A", if the monthly tasks are named differently you will need to change how curTask is set.

    2.Add a new sub to your macro for unhide
    [VBA]Sub unHide ()

    ActiveSheet.Rows.Hidden = False

    End Sub[/VBA]
    ------------------------------------------------
    Happy Coding my friends

  5. #5
    VBAX Newbie
    Joined
    Jul 2011
    Posts
    3
    Location
    Quote Originally Posted by CatDaddy
    1. The syntax around choosing the task is based on how it looked in your spreadsheet curTask contains "Task" " " and "A" as it stands because the column headers are named "Task A", if the monthly tasks are named differently you will need to change how curTask is set.

    2.Add a new sub to your macro for unhide
    [vba]Sub unHide ()

    ActiveSheet.Rows.Hidden = False

    End Sub[/vba]
    Thanks so much!! It works very well.

Posting Permissions

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