So i had this code
Dim cell As Range
Dim rng As Range
Dim FoundRange As Range
Set rng = Range("L54:L4000")
For Each cell In rng.Cells
If cell.DisplayFormat.Interior.ColorIndex = 19 Then
If FoundRange Is Nothing Then
Set FoundRange = cell
Else
Set FoundRange = Union(FoundRange, cell)
End If
End If
Next cell
If Not FoundRange Is Nothing Then FoundRange.Select
End sub
It selects all cells with a specific color. It works fine on simple sheets, but I have a sheet full of tables I need it to work on as well. At the moment it only selects the cells on the first sheet. My solution was to try and apply it to each table, so i tried this:
Sub Validation()
Dim co As ListObject
Dim cell As Range
Dim rng As Range
Dim FoundRange As Range
Set rng = Range("L54:L4000")
For Each co In ActiveSheet.ListObjects
For Each cell In rng.Cells
If cell.DisplayFormat.Interior.ColorIndex = 19 Then
If FoundRange Is Nothing Then
Set FoundRange = cell
Else
Set FoundRange = Union(FoundRange, cell)
End If
End If
Next cell
If Not FoundRange Is Nothing Then FoundRange.Select
Next co
End sub
The first code applied for each cell and I wanted to treat it as an "integer" and apply it for each table, but I'm bad at coding and it obviously didn't work. Can anyone help please?