error in code help

C

Corey

Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim MyRange As Range
Set MyRange = B8: R30 <==== I am getting an error here WHY??
If Not Application.Intersect(Target, MyRange) Is Nothing Then Call
OpenCalendar
End Sub
 
M

Mark

Corey said:
Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim MyRange As Range
Set MyRange = B8: R30 <==== I am getting an error here WHY??
If Not Application.Intersect(Target, MyRange) Is Nothing Then Call
OpenCalendar
End Sub

The way you have this typed, you are setting the Range Object, MyRange,
equal to a string: "B8:R30". What you want to do is set MyRange equal
to another Range Object. That is done like this:

Set MyRange=Range("B8:R30")

Hope that explains it, I had a hard time learning that when I first
started.
Asta-La-Seeya.....
 

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