Filtering data using macro

ramkumarcn

Board Regular
Joined
Jun 21, 2011
Messages
114
I have a range of data in a workbook. I have recorded the macro to filter a value called "report" from a column. It works, but there are chances that this value "report" may not exist. So if macro finds that particular value, it should display a msg saying "data found" else "not found". could you please help me with the code?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Paste into a Standard Module and then Run

Code:
Sub Get_AF_Range()
RowNum = ActiveSheet.AutoFilter.Range(1).Row
ColNum = ActiveSheet.AutoFilter.Range(1).Column
ColCnt = ActiveSheet.AutoFilter.Range.Columns.Count
Set Rng = Range(Cells(RowNum, ColNum), Cells(RowNum, ColNum + ColCnt - 1))
For Each c In Rng.Cells
If c = "Report" Then
Flag = True
End If
Next c
If Flag Then
MsgBox "Data Found"
Else
MsgBox "Not Found"
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,390
Members
452,909
Latest member
VickiS

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top