View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
DocBrown DocBrown is offline
external usenet poster
 
Posts: 119
Default Want to blank some cells when an AutoFilter is active.

I have a budget table that has a Allocated budget amount, Expenses and a
remaining balance:

Allocated Expenses Remaining
Budget Subtotal Balance
-----------------------------------------
$500.00 $300.00 $200.00

The Expense Subtotal is a sum of column of values below this header say
H30:H100. The Subtotal is of the rows that are visible so say there are two
values, $100.00 and $200.00 and $100.00 is hidden by an autofilter. Then
Subtotal will become $200.00. If an auto filter is active I want to blank the
Remaining Balance field.

I have a function that will return a string 'true' if an autofilter is active:

Function MyFilters() As String

Dim i As Integer
Dim rng As Range

'Debug.Print "- MyFilters: " & Err.Number
On Error GoTo ErrThisFun
MyFilters = False
With ActiveSheet.AutoFilter
'Debug.Print "-- MyFilters: Auto:" & .Range.Address
For i = 1 To .Range.Columns.Count
With .Filters(i)
If .On Then
MyFilters = True
End If
End With
Next
End With
GoTo ExitFun

ErrThisFun:
'Debug.Print "-- MyFilters: ERR: " & Err.Number
Resume ExitFun

ExitFun:
'Debug.Print "<- MyFilters: " & Err.Number

End Function

Of course, this function could return a boolean.

How can I use this function to blank the Remaining Balance cells? I tried
making it a UDF and adding Application.Volatile and Public, but that causes
another unrelated macro that modifies other cells to fail with RunTime Error
1004. Anything that runs the MyFilters causes the other macros to fail.

Any ideas?
John S.