This question is maybe more about flow control within a class and how to use class subs or defining the scope of the variables.
This class is intended to Take a predefined range as an input (Source range). There are various flags within this range that I will search for and use the class properties to call these values out as needed.
I'm not sure how or where I should call the Inner Class Sub (or if it is a class method) in order to harvest out that specific area within the range which satisfies the flag.
If you look at the code, I've been able to successful SET the pSourceRange
in the code and Have used the Property Get Title
(which returns Null
) but I'm not sure how I should call the sub within the class to fish out that title from the range. Should this class be public or private? Is it a method? should it be ran after Range SET or Title GET statement?
I've tried pointing out the options I've tried (which are now commented out with error codes.
''''''''''''''''''''''Module Code''''''''''''''''''''''''''
Public Sub AA_StandardCode()
dim testrange as range
'test range does already exist as range
Set TestRange = Range("A1:b100")
Dim HarvestClass As New HarvestCode
Set HarvestClass.SourceRange = testrange
'Error Runtime 424: object required
'HarvestClass.GrabStaticOuterCode(TestRange)
MsgBox HarvestClass.Title
' a Null value is returned, implying nothing was entered
End Sub
''''''''''''''''''''''Class Module Code''''''''''''''''''''
Option Explicit
'Static Contents
Private Const cTitle As String = "1111111,"
Private pSourceRange As Range
Private pTitle As String
Public Property Set SourceRange(Value As Range)
Set pSourceRange = Value
'Error Runtime 424: object required
'GrabStaticOuterCode(pSourceRange)
End Property
Public Property Get Title() As String
'Error Runtime 424: object required
'GrabStaticOuterCode(pSourceRange)
Title = pTitle
End Property
'''''''''''''''
Public Sub GrabStaticOuterCode(pSourceRange As Range)
Dim rng As Range
Dim strTest As String
For Each rng In pSourceRange
strTest = Mid(rng, 1, 4)
Select Case strTest
Case cTitle
pTitle = Mid(strTest, 5, Len(strTest))
Case Else
End Select
Next rng
End Sub