excel vba returning values from a sub
How do I return values from a subroutine in Excel VBA? It appears that I have to "temporarily" store a value elsewhere on the spreadsheet and recover when I return to the main part of the program.
Simply the program runs and asks the user to enter data on several forms, but this data has to be "saved" so it can be used later. Is this a "feature" and my "work-around" is the correct way to achieve this?
e.g.
SelectWhat.Show ' Display Form
WhatToDo = Sheet2.Cells(5, 252) 'recover info
.
.
.
.
.
Private Sub CommandButton1_Click()
End Sub
Private Sub SelectOrder_Click()
Sheet2.Cells(5, 252).Value = "Order" 'Save data for later
Unload Me
End Sub
Private Sub SelectQuote_Click()
Sheet2.Cells(5, 252).Value = "Quote"
Unload Me
End Sub
Private Sub SelectInvoice_Click()
Sheet2.Cells(5, 252).Value = "Invoice"
Unload Me
End Sub
Private Sub SelectView_Click()
Sheet2.Cells(5, 252).Value = "View"
Unload Me
End Sub
Private Sub UserForm_Click()
End Sub