SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 101 | Next

Jim DeMarco

"Pro Excel 2007 VBA"


In the VBE, add a new class module and name it cData. Add a second new class module
and name it cExcelSetup. These will contain the code that will provide all of the functionality
provided in our standard code module.
CHAPTER 2 n DATA IN, DATA OUT 88
Let??™s work with cExcelSetup first, and create an object that can provide our worksheet
setup and cleanup functionality.
Add three module-level variables:
Private m_xlSheet As Worksheet
Private m_rngInitialCellSelect As Range
Private m_rngDataRegionStart As Range
These are the private variables that will hold key property values for us. Next we??™ll create
read/write properties to set and retrieve our property values:
Public Property Get Worksheet() As Worksheet
Set Worksheet = m_xlSheet
End Property
Public Property Set Worksheet(newSheet As Worksheet)
Set m_xlSheet = newSheet
End Property
Public Property Get InitialCellSelection() As Range
Set InitialCellSelection = m_rngInitialCellSelect
End Property
Public Property Set InitialCellSelection(newCell As Range)
Set m_rngInitialCellSelect = newCell
End Property
Public Property Get DataRegionStart() As Range
Set DataRegionStart = m_rngDataRegionStart
End Property
Public Property Set DataRegionStart(newCellAddress As Range)
Set m_rngDataRegionStart = newCellAddress
End Property
The GetInitialCellSelection and DataRegionStart properties both return Range objects.
We??™ll be using the GetInitialCellSelection property to determine where our cursor will be
after our code runs.


Pages:
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113