Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Userform

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    England
    Posts
    212
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I'm using a Userform to collect 4 fields of data e.g. name,date,priority and date finished. I'm then inserting the data into row 7, A7 to D7. I want the userform to ask the user if any more entries are required and if so bring the userform up again but this time insert the data into row 8 and so forth until the user has finished entering all data.

    Can someone help me with the code so the userform collects data, inserts the data in the required row, prompts if any more entries are required, if so clears the userform and asks the user to enter details and insert in the next row until the user has no further entries to make and then closes the userform.

    Hope someone can understand and help!

    thanks

    Matt

  2. #2
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Matt


    Let's say your UserForm has 4 Textboxes called Textbox1 to 4. Try some code like this



    Code:
    Private Sub CommandButton1_Click()
    Dim iReply As Integer
    
    If iRow = 0 Then iRow = 1
    If iCol = 0 Then iCol = 7
    
    With Sheet1
        .Cells(iRow, iCol) = Textbox1
         Textbox1 = ""
         iRow = iRow + 1
         
         
        .Cells(iRow, iCol) = textbox2
         textbox2 = ""
         iRow = iRow + 1
        
         
        .Cells(iRow, iCol) = textbox3
         textbox3 = ""
         iRow = iRow + 1
       
         
         .Cells(iRow, iCol) = textbox4
         textbox3 = ""
         iRow = iRow + 1
         
         iCol = iCol + 1
    End With
    
    iReply = MsgBox("More Entries?", vbYesNo)
             If iReply = vbNo Then Unload Me
             
    Textbox1.SetFocus
    End Sub
    _________________
    Kind Regards
    Dave Hawley
    OzGrid Business Applications
    Microsoft Excel/VBA Training




    [ This Message was edited by: Dave Hawley on 2002-04-08 04:50 ]

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    England
    Posts
    212
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks Dave

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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