Results 1 to 1 of 1

Run second VBA with out affecting another one

Threaded View

Ireland316 Run second VBA with out... 06-08-2012, 07:05 AM
  1. #1
    Registered User
    Join Date
    04-26-2012
    Location
    Skelmersdale, England
    MS-Off Ver
    Excel 2007
    Posts
    2

    Run second VBA with out affecting another one

    Hi.

    I have a Training database to record what training people have received.
    I have all employees on one sheet then have a user form with option to select a work line, this then hides all columns and row that are not associated with those areas.

    Private Sub OptionButton2_Click()
    Range("A8:A250").Select
        Selection.EntireRow.Hidden = False
        Range("A8:A19,A37:A250").Select
        Selection.EntireRow.Hidden = True
        Range("A9").Select
        BeginColumn = 9
        EndColumn = 160
        ChkRow = 4
         
        For ColCnt = BeginColumn To EndColumn
            If Cells(ChkRow, ColCnt).Value = "SAJ" Then
                Cells(ChkRow, ColCnt).EntireColumn.Hidden = False
            Else
                Cells(ChkRow, ColCnt).EntireColumn.Hidden = True
            End If
        Next ColCnt
        
        UserForm1.Hide
    End Sub
    This works perfectly.

    I want to insert another user form to run a filter on top of the original one that will hide columns based on Job role or primary area of work.

    This is the code i have:

    Private Sub OptionButton1_Click()
     
        BeginColumn = 9
        EndColumn = 16
        ChkRow = 5
         
        For ColCnt = BeginColumn To EndColumn
            If Cells(ChkRow, ColCnt).Value = "MT" Then
                Cells(ChkRow, ColCnt).EntireColumn.Hidden = False
            Else
                Cells(ChkRow, ColCnt).EntireColumn.Hidden = True
            End If
        Next ColCnt
    
        
        UserForm3.Hide
    End Sub
    This works in that it hides columns based on the job role in row 5 but it unhides the ones that the original filter had hidden.

    I need help in setting the range for the second so it only applies it to visible columns, i have tried various versions of offset or specialcellvisible codes but can't get it to work.

    Anyone got any ideas on this? Your help would be greatly appreciated.

    Ireland316
    Last edited by Ireland316; 06-13-2012 at 04:06 AM.

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