I'm very new to macros. I have an income statement by month with an ActiveX Combobox containing the various departments. On a separate sheet called "Analysis" (in the same format minus the drop down list) is calculating % of revenue. In column P is a formula to give me "1" if any month (Jan-Dec) contains a cost that is greater than 5% and "0" if not. I want to see every row(cost) that contains 5% or greater. I want all of the rows within my range to hide or unhide anytime the user makes a new selection from the drop down list. I have some codes that work but not automatically. Every time I make a different selection I have to open up the vba and hit F5 to run it. Here are 2 codes I've tried and work but do not auto hide/unhide when a new selection from drop down list is made. Any help will be GREATLY appreciated.
Sub HideRows()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
BeginRow = 22
EndRow = 300
ChkCol = 16
For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = "" Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
ElseIf Cells(RowCnt, ChkCol).Value = 1 Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
----------------------------------------------------------------------
Private Sub Worksheet_Activate()
If MyVal = "" And [B11] <> "" Then MyVal = [B11] & ""
End Sub
Private Sub Worksheet_Calculate()
Dim CELL As Range
If [B11] <> MyVal Then
For Each CELL In Range("P22:P300")
Rows(CELL.Row).Hidden = CELL = 0
Next CELL
MyVal = [B11] & ""
End If
End Sub
Bookmarks