2

I'm setting up the userform based on User input of 1 to 5, however, I can't seem to get this input into the Userform_Initialise sub.

Public TP As String 'this is in ThisWorkbook; from here

Private Sub Workbook_Open()

Dim RT As String

ReEnter:

    RT = Application.InputBox("1 - Monthly" & vbNewLine & "2 - Quarterly" & vbNewLine & "3 - Semi-Annually" & _
    vbNewLine & "4 - Semi-Annually" & vbNewLine & "5 - Others", "Type of 
    Report", "Enter Number Here", Type:=1)
    If RT >= 1 And RT <= 5 Then
        TP = Val(RT)
    Else
        MsgBox "Error", vbCritical
        GoTo ReEnter

    End If

UserForm1.Show

End Sub 'to here

'This onwards is in Userform
Private Sub Userform_Initialize()

Debug.Print TP

End Sub

How do I get the code to recognise the User Input TP in the Userform? Thanks in advance!

0

1 Answer 1

2

Declare your global variable in a module

Public TP As String 'this should be in a module

or if it is declared in ThisWorkbook you must use

Debug.Print ThisWorkbook.TP

in your UserForm.

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.