2

I have a module class file "CombinaisonLine" in my class modules folder :

Private pAdult As String
Private pChild As String
Public Property Get Adult() As String
    Adult = pAdult
End Property
Public Property Let Adult(Value As String)
    pAdult = Value
End Property

Public Property Get Child() As String
    Child = pChild
End Property
Public Property Let Child(Value As String)
    pChild = Value
End Property

In my modules folder, I have a function called when I click on a button in my sheet :

Function Test()
Dim Line As CombinaisonLine   
If (Sheets("Feuil1").Cells(3, 6).Value = "YES") Then
        Line.Adult = "1"
        Line.Child = "0"            
End If
End Function

I am getting an error 91 at line "Line.Adult="1"" with the following message (I am using a french version, so I have translated the message into english):

execution error "91":
Object variable or Bloc variable With not defined

I don't know what I am missing. Thanks in advance for your help

1 Answer 1

3

You need to create object of class CombinaisonLine first, and destroy when you do not need it:

Function Test()
Dim Line As CombinaisonLine 

Set Line = New CombinaisonLine

If (Sheets("Feuil1").Cells(3, 6).Value = "YES") Then
        Line.Adult = "1"
        Line.Child = "0"            
End If

Set Line = Nothing

End Function
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.