DRJD
08-19-2008, 07:04 AM
Hi,
I'm trying to code a class at the moment and I want to set a range as one of it's properties. Is this going to be possible? I've included a snippet of the code that I can't get to work. Can anyone point out what I am missing?
The class module code, titled Class1:
Option Explicit
Dim rg As Range
Public Property Get StartCell() As Range
StartCell = rg
End Property
Public Property Let StartCell(Value As Range)
rg = Value
End Property
The test code:
Option Explicit
Sub ClassTest()
Dim Class1 As Class1
Dim rg As Range
Set Class1 = New Class1
Set rg = ThisWorkbook.Worksheets(1).Range("A1")
Class1.StartCell = rg
End Sub
When I run this I get the following error: "Run Time Error 91: Object Variable or With block variable not set".
Any ideas?
I'm trying to code a class at the moment and I want to set a range as one of it's properties. Is this going to be possible? I've included a snippet of the code that I can't get to work. Can anyone point out what I am missing?
The class module code, titled Class1:
Option Explicit
Dim rg As Range
Public Property Get StartCell() As Range
StartCell = rg
End Property
Public Property Let StartCell(Value As Range)
rg = Value
End Property
The test code:
Option Explicit
Sub ClassTest()
Dim Class1 As Class1
Dim rg As Range
Set Class1 = New Class1
Set rg = ThisWorkbook.Worksheets(1).Range("A1")
Class1.StartCell = rg
End Sub
When I run this I get the following error: "Run Time Error 91: Object Variable or With block variable not set".
Any ideas?