On the SetNum sheet is an ordered list of data sets. (the first set is set 0) The data itself is stored on a different sheet (Data). I would like the user to click the ModifySet button, enter a number, and have the form pop up with the previously entered data.
The SetNum control is an invisible label used for tracking the current set number. Its default value is 0.
The code for the button:
Private Sub ModifySet_Click()
SetForm.SetNum.Caption = InputBox("Please Enter Set Number", "Count Request Wizard")
If SetForm.SetNum.Caption > 0 And SetForm.SetNum.Caption <= WorksheetFunction.Max(Worksheets("SetNum").Range("B:B")) Then
Debug.Print "Test " & SetForm.SetNum.Caption
SetForm.Show
Else
MsgBox ("Sorry, set number not valid.")
End If
End Sub
In theory, this is what should be pulling of the previous data entered. All of the controls have a corresponding named column in "Data". On Error is included since not all controls (such as labels) need/have their own column.
Private Sub UserForm_Initialize()
On Error Resume Next
Debug.Print "Int " & SetForm.SetNum.Caption
For Each Control In SetForm.Controls
Name = Control.Name
Control.Value = Worksheets("Data").Cells(SetForm.SetNum.Caption + 2, Worksheets("Data").Range(Name).Column).Value
Next Control
End Sub
Here is what I get from the two Debug.Print commands.
What I get is the UserForm coming up after I've input the SetNum with a SetNum.Caption of the correct value, but the data is always from Set0 (the default value for SetNum.Caption)
Am I just overlooking something?
Thanks,
Magness
Bookmarks