I have a very simple Class definition. Class Sheetwriter is defined as follows:
Option Explicit
'Works off of the ActiveCell
'Helps you write data into the cells
Private pCornerCell As String
Public Property Get CornerCell()
CornerCell = pCornerCell
End Property
Public Property Let CornerCell(Value As String)
pCornerCell = Value
Range(Value).Select
End Property
I get a compile error that I don't understand. Definitions of property procedures for the same property are inconsistent, or the property procedure has an optional parameter. What am I doing wrong?
Public Property Get CornerCell()
That's returning an implicit Variant
, since no return type was specified.
Public Property Get CornerCell() As String
That's returning the String
that the compiler is seeing in the Property Let
member, and fixes your problem.
FWIW, that Range(Value).Select
statement doesn't belong in there at all, and you don't want to work off the active cell and sprinkle Select
and Activate
statements everywhere.
See How to avoid using Select in Excel VBA macros for some tips about avoiding that.