ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   error in code help (https://www.excelbanter.com/excel-programming/370061-error-code-help.html)

Corey

error in code help
 
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


--
Regards

Corey



Mark

error in code help
 

Corey wrote:
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


--
Regards

Corey


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.....



All times are GMT +1. The time now is 05:50 PM.

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