check an ective cell against a defined range

dyerstm

New Member
Joined
Sep 4, 2003
Messages
12
I have a sub routine that checks if the ActiveCell.Value is within a specified range(("A7:A46") but I cant get it to work, what I'm trying to do is ensure that when a user clicks my command button it checks the active cell and compares it to range("A7:A46")

I have something like this

Private Sumb Cmdbutton_Click()

if activeCell.value <> myRange("A7:A46")
...indicate error!

but I can't get it to work
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
To check if a cell is in a range try using Intersect.
Code:
If Not Intersect(ActiveCell, Range("A7:A46") Is Nothing Then
     ' active cell is in range so run code
Else
     ' active cell is not in range
     Msgbox "Select a cell within the appropriate range please"
End If
 
Upvote 0
I think that the OP wants to check the value of the active cell with the values in A6:A47.

But she/he does not explain what sort of check is required - i.e. whether to check that the value exists in the range, or whether the value is within (or perhaps not outside of) the range of values within the range, or something else
 
Upvote 0

Forum statistics

Threads
1,215,751
Messages
6,126,669
Members
449,326
Latest member
asp123

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