error in code help

  • Thread starter Thread starter Corey
  • Start date Start date
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
 
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.....
 
Back
Top