Macro to Compare one cell to a range of cells

Jmg4326

New Member
Joined
May 11, 2011
Messages
3
Hello everyone - I am trying to create a macro that has in if then statement that is relying on whether or not the value of one cell is found within the range of a bunch of cells. It looks like the below. Any suggestions?

If ActiveCell.Value <> Range("F7:F130").Value Then
ActiveCell.Offset(0, 1).Select
Else: Selection.EntireRow.Select
Selection.Delete
End If
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try

Code:
If IsError(Application.Match(ActiveCell.Value, Range("F7:F130"), 0)) Then
    ActiveCell.Offset(0, 1).Select
Else
    ActiveCell.EntireRow.Delete
End If
 
Upvote 0

Forum statistics

Threads
1,224,605
Messages
6,179,860
Members
452,948
Latest member
UsmanAli786

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