Determine if column is within range of columns

M

Michael Beckinsale

Hi All,

Does anybody have the code to determine if the ActiveCell is within a range
of columns ie F:CZ ?

I think l should be able to use the Intersect function if l state the full
range (ie F6:CZ5006) but have had no luck so far.

For various reasons l cannot restrict the selection of cells by locking and
using = xlUnlockedCellsOnly using the worksheet activate event.

All help / suggestions gratefully received

Regards

Michael Beckinsale
 
B

Bob Phillips

Not Intersect(activecell,range("F:CZ")) Is Nothing

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
M

Michael Beckinsale

Bob,

Sorry l must have my "dense" head on this morning!

How do l use this code? somrthing like this ?

If Not Intersect(activecell,range("F:CZ")) Is Nothing Then
Exit sub
Else
Code to do something

Regards

Michael
 
B

Bob Phillips

Hi Michael,

No the other way around

If Not Intersect(activecell,range("F:CZ")) Is Nothing Then
Code to do something

because the Intersect will return Nothing if they don't (intersect that is),
so Intersect(...) Is Nothing checks if they don't intersect, the Not checks
the negative of that (i.e if they DO intersect).

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
M

Michael Beckinsale

Bob,

I realised it was the wrong way round as soon as l sent it to you. However
it was my mistake, l didn't put a space between NotIntersect!
I'm being a real dimlo this morning.

Many thanks for your help

Michael
 

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