+ Reply to Thread
Results 1 to 3 of 3

retrieve data from the worksheet in Userform

Hybrid View

  1. #1
    Registered User
    Join Date
    08-07-2012
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    45

    Unhappy retrieve data from the worksheet in Userform

    Can anybody help to find out why the data cant be retrieved in the userform? i was stuck with the problem~.~
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: retrieve data from the worksheet in Userform

    Private Sub TextBox0_Change()
        Dim i As Long
        
        If TextBox0.ListIndex > -1 Then
            i = TextBox0.ListIndex
            With Sheets("OSH").Range("B6")
                TextBox1.Value = .Offset(i, 1).Value
                TextBox2.Value = .Offset(i, 2).Value
                TextBox3.Value = .Offset(i, 3).Value
                TextBox4.Value = .Offset(i, 4).Value
            End With
        Else
            TextBox1.Value = ""
            TextBox2.Value = ""
            TextBox3.Value = ""
            TextBox4.Value = ""
        End If
    
    End Sub
    
    
    Private Sub CommandButton1_Click()
        Dim i As Long
        
        If TextBox0.ListIndex > -1 Then
            i = TextBox0.ListIndex
            With Sheets("OSH").Range("B6")
                .Offset(i, 1).Value = TextBox1.Value
                .Offset(i, 2).Value = TextBox2.Value
                .Offset(i, 3).Value = TextBox3.Value
                .Offset(i, 4).Value = TextBox4.Value
            End With
            
            MsgBox "Record Updated"
            Unload Me
        Else
            MsgBox "No name selected. ", , "Invalid Name"
        End If
        
    End Sub
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    08-07-2012
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    45

    Re: retrieve data from the worksheet in Userform

    Dear AlphaFrog
    Thank you very much!

+ 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. Use textbox in userform to retrieve data
    By Fogsta65 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-12-2013, 04:59 PM
  2. Automatically Retrieve Data From a worksheet to userform
    By DKTRL in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-24-2013, 02:25 PM
  3. Retrieve data from excel in userform to edit
    By Daantje71 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-02-2013, 03:06 PM
  4. Hi. anyone can help me to link this? userform and retrieve data problem
    By yuki0219 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2012, 11:36 AM
  5. Would like to retrieve data from spreadsheet to userform
    By Bucko in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-03-2006, 09:15 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