Results 1 to 10 of 10

Waiting for Input

Threaded View

  1. #1
    Registered User
    Join Date
    12-08-2009
    Location
    Madison, WI
    MS-Off Ver
    Excel 2003
    Posts
    30

    Waiting for Input

    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.

    Int 0
    Test 1
    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
    Last edited by magness; 01-14-2010 at 04:32 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1