Sub ChangeValuesBasedOnFilter()
Dim ws As Worksheet
Dim rngData As Range
Dim cellA As Range
Dim cellB As Range
' Set the worksheet (change "Sheet1" to your actual sheet name)
Set ws = ThisWorkbook.Sheets("Sheet1")
' Assuming your data starts from row 2 in columns A and B
Set rngData = ws.Range("A2:B" & ws.Cells(ws.Rows.Count, "A").End(xlUp).Row)
' Loop through visible cells in Column A
For Each cellA In rngData.Columns(1).SpecialCells(xlCellTypeVisible)
' Check if Column B is filtered
If Not ws.AutoFilterMode Then
Exit Sub
End If
' If Column B is visible and not hidden by the filter, change its value based on Column A
If Not rngData.Columns(2).Cells(cellA.Row, 1).EntireRow.Hidden Then
Set cellB = rngData.Columns(2).Cells(cellA.Row, 1)
' Your condition to change the value in Column B based on Column A
If cellA.Value = "YourCondition" Then
cellB.Value = "NewValue"
End If
End If
Next cellA
' Clear the filter to show all data
ws.AutoFilterMode = False
End Sub