Question : Excel / VBA: Code must check if there is any Cell in some filtered rows highligthed in RED...If so code must not run.

Hi,

I have a code (attached here)  that actually checks if the data in the worksheet has been filtered by column C.

What I need is that once the Data has been correctly filtered by Column C, then the code also checks in the visible rows that there is no cells in columns F,G,I and J that are no cells highligthed (think that the right word is colorindex) in RED.

Cells in those columns (F,G,I and H) will turn RED trough Conditional Formatting.

If there is any cell in RED the code must not RUN and show a Message Box saying That there are still cells waiting for info.

Could you help me ?

Regards,
Roberto.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
If Not ActiveSheet.FilterMode Then
        MsgBox "DEBE FILTRAR POR FECHA DE ENTREGA (COLUMNA C) ANTES DE CONTINUAR"
        Exit Sub
ElseIf Application.Evaluate("Filteron(C6)") = False Then
 
        MsgBox "DEBE FILTRAR POR FECHA DE ENTREGA (COLUMNA C) ANTES DE CONTINUAR"
        Exit Sub
        
    End If
'then here comes the rest of the code....
 
 
 
'this Function goes in module 1 in order the code runs in the right way:
 
Function FilterOn(rngCell As Range) As Boolean
   On Error GoTo err_handle
   Application.Volatile True
   With rngCell.Parent.AutoFilter
      With .Filters.Item(rngCell.Column - .Range.Column + 1)
         FilterOn = .On
      End With
   End With
    
Clean_up:
   Exit Function
    
err_handle:
   FilterOn = False
   Resume Clean_up
End Function

Answer : Excel / VBA: Code must check if there is any Cell in some filtered rows highligthed in RED...If so code must not run.

Roberto,

You cant do like this, You need to check each cell for it some thing like this......But not this will throw out an error if column-F,G,I,J are merged cells because in merge they will consider the value in top cell and will consider rest of the cells are blank.

Saurabh...

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
    Dim rng As Range, cell As Range, lrow As Long
 
    lrow = Cells(Cells.Rows.Count, "f").End(xlUp).Row    '<-- Finding last row basis of F Column
 
    Set rng = Range("F2:G" & lrow & ",I2:J" & lrow).SpecialCells(xlCellTypeVisible)
 
    For Each cell In rng
        If Range("A" & cell.Row).Value <> "" And cell.Value = "" Then
 
            MsgBox "You have blank Value in --> " & cell.Address & " where column A " & cell.Row & " is not blank"
            Exit Sub
        End If
    Next 
Random Solutions  
 
programming4us programming4us