Private Sub Worksheet_Change(ByVal Target As Range)
If IsFiltered(ActiveSheet) Then
lr = ActiveSheet.UsedRange.Rows.Count
If (Target.Column = Range("Response").Column) Then
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
'Declare range you are checking for visible cells - should be dynamic
Dim r As Range
'Declare output range variable
Dim visibleCells As Range
'Set range checking against
Set r = Range(Cells(2, Target.Column), Cells(lr, Target.Column))
'Set visible range
Set visibleCells = r.SpecialCells(xlCellTypeVisible)
'Loop to apply condition to each cell that is visible
For Each cell In visibleCells
cell.Value = Target.Value
Next
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End If
If IsFiltered(ActiveSheet) Then
End If
End Sub
Private Function IsFiltered(SheetName As Worksheet) As Boolean
Dim lr As Long
Dim n As Integer
'Count Columns
lr = SheetName.UsedRange.Columns.Count
'Loop through columns to check if each column is filtered
For n = 1 To lr
If SheetName.AutoFilter.Filters(n).On Then
'Skip to end - your data is filtered if this is True
GoTo FiltersOn
Else
End If
Next n
'Code to Exit Sub - your data is not filtered
IsFiltered = False
Exit Function
'Code for applying IsFiltered = True when data is filtered
FiltersOn:
IsFiltered = True
I tried to follow your instruction but it didn't work, maybe I put them in the wrong position? Could you please advise and help to combine that for me please. Many thanks!
Bookmarks