Problem determining whether a cell is within a Range

S

SaeOngJeeMa

Hi, I'm trying to use Intersect to determine if a cell is within a known
range. See excerpt from my code below. The Intersect is causing an error. Any
suggestions on what's wrong with my code, or maybe a different way to do
this? Thanks in advance for any help you can provide.
Best Regards,
Dean

*******************************
Public grngFSF As Range

With Worksheets("FSF")
.Activate
.Range(Cells(5, 1), ActiveCell.SpecialCells(xlLastCell)).Select
Set grngFSF = Selection
End With

If Intersect(grngFSF, Worksheets("FSF").Cells(lngRow, lngCol)) Is Nothing Then
bytReturnValue = 0
Else
bytReturnValue = 1
End If
*******************************
 
B

Bob Phillips

Does lngRow, lngCol have valid values?

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
S

SaeOngJeeMa

Hi Bob,
Yes, they are both valid integers. I also tried by replacing the offending
statement with the following, but still get an error.

If Intersect(grngFSF, Worksheets("FSF").Cells(10, 10)) Is Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top