+ Reply to Thread
Results 1 to 2 of 2

Userform to go throw each row of data with a "next" button

Hybrid View

  1. #1
    Registered User
    Join Date
    02-10-2014
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    19

    Userform to go throw each row of data with a "next" button

    Say I have a worksheet
    Number | First Name | Last Name as the column labels
    then a variable amount of data

    for this example:

    Number First Name Last Name
    1 John Doe
    2 John Smith
    3 Kelly Scott
    4 Andrew Clarke


    example1.JPG

    I need help with a user form that populates certain text boxes based on the data with each row.
    Each time you click a button "next" the data goes to the next row of data.

    example2.JPG

    So when the form initializes, it has
    Number: 1
    Name: John Doe


    you click the next button, and it populates
    Number: 2
    Name: John Smith


    and does this until the last row of data.

    Any suggestions?

  2. #2
    Registered User
    Join Date
    02-10-2014
    Location
    Atlanta, Georgia
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Userform to go throw each row of data with a "next" button

    Nevermind, got it! Here is my code for any future-goers

    Dim i As Long, j As Long
    Dim rng As Range
    
    Private Sub CommandButton1_Click()
        Set rng = Worksheets("Import").Range("B2")
    
        i = 0: j = 1
    
        Dashboard.TextBox1.Text = rng.Offset(i).Value
        Dashboard.TextBox2.Text = rng.Offset(i, j).Value: j = j + 1
        
        '
        '
        'txtbox_revri_projname.SetFocus
    End Sub
    
    
    '~~> Next Button
    Private Sub CommandButton2_Click()
    
        i = i + 1: j = 1
    
        If i > (Sheets("Import").UsedRange.Rows.Count - 2) Then
            MsgBox "Last Record"
            Exit Sub
        End If
    
        Dashboard.TextBox1.Text = rng.Offset(i).Value
        Dashboard.TextBox2.Text = rng.Offset(i, j).Value: j = j + 1
    
        '
        '
        'txtbox_revri_projname.SetFocus
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 10-23-2013, 05:20 PM
  2. Userform to store "option button value" in specific column
    By Luis21 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2013, 12:48 PM
  3. Replies: 0
    Last Post: 12-10-2012, 04:34 AM
  4. [SOLVED] Code for a "next" button within a multi-page UserForm
    By eemiller1997 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-12-2012, 05:45 PM
  5. creating "Find" button on userform for editing data
    By madhg in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-11-2009, 04:35 AM

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