+ Reply to Thread
Results 1 to 14 of 14

Populate cell values into 6 named text boxes in a userform then edit if required

Hybrid View

How How Populate cell values into 6... 02-22-2013, 11:11 AM
Norie Re: Populate cell values into... 02-22-2013, 11:17 AM
How How Re: Populate cell values into... 02-22-2013, 01:29 PM
Norie Re: Populate cell values into... 02-22-2013, 01:35 PM
How How Re: Populate cell values into... 02-22-2013, 01:39 PM
Norie Re: Populate cell values into... 02-22-2013, 01:45 PM
Norie Re: Populate cell values into... 02-22-2013, 02:04 PM
How How Re: Populate cell values into... 02-22-2013, 02:52 PM
Norie Re: Populate cell values into... 02-22-2013, 03:04 PM
How How Re: Populate cell values into... 02-25-2013, 08:17 AM
Norie Re: Populate cell values into... 02-25-2013, 10:35 AM
How How Re: Populate cell values into... 02-25-2013, 11:42 AM
Norie Re: Populate cell values into... 02-25-2013, 11:49 AM
How How Re: Populate cell values into... 03-05-2013, 05:51 AM
  1. #1
    Registered User
    Join Date
    06-25-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2019 / 365
    Posts
    71

    Populate cell values into 6 named text boxes in a userform then edit if required

    Hi, Can someone help please? In a userform Is it possible to have 1 text box that I can enter a unique value (eg 4B) from Col B & then have the values of column A, B, C, D, E & F from the row that has the unique value (Using unprotect/protect), then edit & send if required.

    P.s I’m using excel 2010

    Thanks

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Populate cell values into 6 named text boxes in a userform then edit if required

    You don't need to protect/unprotect to put the values in the texboxes, but you will need it if you want to alter the data on the worksheet.

    To find the row the unique value is on you could use match, and with that you can populate the textboxes.

    Here's a rough example of what I mean.
    Dim res As Variant
    
       res = Application.Match(Textbox1.Value, Worksheets("Sheet1").Range("B:B") , 0)
    
       If Not IsError(res) Then
               TextBox2.Value = Worksheets("Sheet1").Range("A" & res).Value
               TextBox3.Value = Worksheets("Sheet1").Range("C" & res).Value
               TextBox4.Value = Worksheets("Sheet1").Range("D" & res).Value
               TextBox5.Value = Worksheets("Sheet1").Range("E" & res).Value
               TextBox6.Value = Worksheets("Sheet1").Range("F" & res).Value
       End If
    Obviously you'd need to change that for your setup - perhaps you could attach a sample workbook?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    06-25-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2019 / 365
    Posts
    71

    Re: Populate cell values into 6 named text boxes in a userform then edit if required

    Quote Originally Posted by Norie View Post
    You don't need to protect/unprotect to put the values in the texboxes, but you will need it if you want to alter the data on the worksheet.

    To find the row the unique value is on you could use match, and with that you can populate the textboxes.

    Here's a rough example of what I mean.
    Dim res As Variant
    
       res = Application.Match(Textbox1.Value, Worksheets("Sheet1").Range("B:B") , 0)
    
       If Not IsError(res) Then
               TextBox2.Value = Worksheets("Sheet1").Range("A" & res).Value
               TextBox3.Value = Worksheets("Sheet1").Range("C" & res).Value
               TextBox4.Value = Worksheets("Sheet1").Range("D" & res).Value
               TextBox5.Value = Worksheets("Sheet1").Range("E" & res).Value
               TextBox6.Value = Worksheets("Sheet1").Range("F" & res).Value
       End If
    Obviously you'd need to change that for your setup - perhaps you could attach a sample workbook?
    Thanks Norie, I tried the code using a button at the bottom of the first userform to open a 2nd userform but nothing is happening.......I must have done something wrong! I've attached an example which I'm happy I've got that far!! Just need to get the edit bit done.....and......is it also possible to ask the user for a PW before an edit is allowed?

    Thanks for your help
    Attached Files Attached Files

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Populate cell values into 6 named text boxes in a userform then edit if required

    The code I posted was just kind of rough and would have to be changed.

    Why do you mention another userform?

    You should be able to do everything with the one userform, more than that seems complicated.

    Anyways, I'll have a look at the workbook.

  5. #5
    Registered User
    Join Date
    06-25-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2019 / 365
    Posts
    71

    Re: Populate cell values into 6 named text boxes in a userform then edit if required

    The reason I used another userform is quite simply I dont know much about this, I'm trying to learn........Hopefully I can pick thinks up as I go!!

    Thanks again

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Populate cell values into 6 named text boxes in a userform then edit if required

    I thought you were using the 2 forms for the same thing.

    Not had a proper look at everything though, a problem with a missing OCX file for the DatePicker control.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Populate cell values into 6 named text boxes in a userform then edit if required

    Since the IDs being looked for are numeric the text from the textbox needs to be converted, otherwise the Match will fail.

    Try this.
    Private Sub Getdata_Click()
    Dim res As Variant
    
       res = Application.Match(Val(TboIDnumber.Value), Worksheets("Sheet2").Range("B:B"), 0)
    
       If Not IsError(res) Then
               TboLogedit.Value = Worksheets("Sheet2").Range("A" & res).Value
               TboDateedit.Value = Worksheets("Sheet2").Range("C" & res).Text
               Tbojobedit.Value = Worksheets("Sheet2").Range("D" & res).Value
               TboLocedit.Value = Worksheets("Sheet2").Range("E" & res).Value
               TboCustomeredit.Value = Worksheets("Sheet2").Range("F" & res).Value
               TboRigedit.Value = Worksheets("Sheet2").Range("G" & res).Value
       End If
    End Sub

  8. #8
    Registered User
    Join Date
    06-25-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2019 / 365
    Posts
    71

    Re: Populate cell values into 6 named text boxes in a userform then edit if required

    Norie, thats filling in the boxes ok....Except if a value of 7B for eg is entered into the ID box, it returns the values from ID number 7 (not 7B).

    have a good weekend (Thnx again)

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Populate cell values into 6 named text boxes in a userform then edit if required

    If there's going to be a mix of numeric and alphanumeric then perhaps Match isn't the way to go.

    Why not have a combobox listing the IDs instead of a textbox?

  10. #10
    Registered User
    Join Date
    06-25-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2019 / 365
    Posts
    71

    Re: Populate cell values into 6 named text boxes in a userform then edit if required

    Norie, I've added a new column in for A which will will give the table a seperate number but will sort as an individual col, which seems to work (wasn't really wanting to add the extra col.........but needs must!!). What is the best way to overwrite the values in the edit form to the table?
    Last edited by How How; 02-25-2013 at 08:19 AM.

  11. #11
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Populate cell values into 6 named text boxes in a userform then edit if required

    Why did you add another column?

  12. #12
    Registered User
    Join Date
    06-25-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2019 / 365
    Posts
    71

    Re: Populate cell values into 6 named text boxes in a userform then edit if required

    So I could enter just a numeric number & that now works, I just need to fit in a send (Enter changes) from the edit userforms

  13. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Populate cell values into 6 named text boxes in a userform then edit if required

    How about a combobox?

    See the attached.

    As for putting the data back on the worksheet, you can just reverse the code that's used to populate the userform, perhaps with a tweak or two.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    06-25-2011
    Location
    Scotland
    MS-Off Ver
    Excel 2019 / 365
    Posts
    71

    Re: Populate cell values into 6 named text boxes in a userform then edit if required

    Thanks for your help Norie.....Great stuff

+ Reply to Thread

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