ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Intersect (https://www.excelbanter.com/excel-programming/367740-intersect.html)

[email protected]

Intersect
 
I run into a code "91" error when I perform this function


sub mymacro()

If application.intersect(Activecell, Range("A1:IV16")) then
msgbox("wrong area")
else
msgbox("better")
end if

end sub

I don't have anything declared, can anyone help?


RB Smissaert

Intersect
 
Instead of ActiveCell do:
Cells(ActiveCell.Row, ActiveCell.Column)

RBS

wrote in message
oups.com...
I run into a code "91" error when I perform this function


sub mymacro()

If application.intersect(Activecell, Range("A1:IV16")) then
msgbox("wrong area")
else
msgbox("better")
end if

end sub

I don't have anything declared, can anyone help?



RB Smissaert

Intersect
 
Forgot to say that you also have to deal with the resulting range like this:

If Not Application.Intersect(Cells(ActiveCell.Row, _
ActiveCell.Column), Range("A1:A10")) Is Nothing Then

RBS

"RB Smissaert" wrote in message
...
Instead of ActiveCell do:
Cells(ActiveCell.Row, ActiveCell.Column)

RBS

wrote in message
oups.com...
I run into a code "91" error when I perform this function


sub mymacro()

If application.intersect(Activecell, Range("A1:IV16")) then
msgbox("wrong area")
else
msgbox("better")
end if

end sub

I don't have anything declared, can anyone help?





All times are GMT +1. The time now is 06:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com