I have worksheet, with two filled columns, a & b, respect to criteria at range("E1") and ("E2")
I need to use VBA to search till the end of rows.
If criteria is meet, the cell with entire row will be selected. However, I'm not able to make a msgbox to alert user there is no data meet the criteria.
The code is as below I appreciate any advise is given.
Sub Testing()
Dim c As Range
Dim rngG As Range
For Each c In Intersect(ActiveSheet.UsedRange, Columns("a"))
If c = Sheet1.Range("E1") Then
If rngG Is Nothing Then Set rngG = c.EntireRow
Set rngG = Union(rngG, c.EntireRow)
End If
Next c
rngG.Select
Dim d As Range
Dim rnG As Range
For Each d In Intersect(ActiveSheet.UsedRange, Columns("b"))
If d = Sheet1.Range("E2") Then
If rnG Is Nothing Then Set rnG = d.EntireRow
Set rnG = Union(rnG, d.EntireRow)
End If
Next d
Intersect(rngG, rnG).Select
End Sub