how to update a record from combo-box in user form?

asafswis2

New Member
Joined
Apr 30, 2013
Messages
1
hello guys.
i really need some help with that thing.
im newbie in vba but rally like all that stuff.


i have this table:

w28i7.jpg
[/URL][/IMG]

and i have a form for a user

sud1g.jpg
[/URL][/IMG]

that i want he can update the table like this:

the user choose a name from the "worker name" combo-box
and when he click on "update" so the "yes/no" column in the table will show "yes" for the name that was chosen by the user.

second thing is that
when the user choose a name and click on the empty button, so it will delete all the record of the name was chosen (all the row).
this is the code of the form so far

Code:
Private Sub cmdAdd_Click()
    Dim lRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("workers")
    
    'בדיקה אם הוכנסו פרטים
    If Trim(Me.cmbWN.Value) = "" Then
      Me.cmbWN.SetFocus
      MsgBox "הכנס שם עובד"
      Exit Sub
    End If
    
    If Trim(Me.tbDate.Value) = "" Then
      Me.tbDate.SetFocus
      MsgBox "הכנס תאריך בחינה"
      Exit Sub
    End If
    
    ActiveWorkbook.Save
    End Sub
    
    Private Sub tbDate_Change()
    
    End Sub
    
    Private Sub UserForm_Initialize()
    Dim cFullName As Range
    
    Dim ws As Worksheet
    Set ws = Worksheets("workers")
    
    For Each cFullName In ws.Range("שםפרטי")
      With Me.cmbWN
        .AddItem cFullName.Value
        .List(.ListCount - 1, 1) = cFullName.Offset(0, 1).Value
      End With
    Next cFullName
    
    tbDate.Text = Sheets("not done").Range("J3").Text
    End Sub

thank for all helpers
 
Last edited:

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hi..

A nudge in the right direction (imo)..

1. Create a dynamic named range that covers your data.
2. Set the Rowsource property of the Combobox to be the named range
3. When updating... Use a Vlookup or Index/Match to find the selected combobox selection in your named range data. Need to find its row position.
4. insert your data (Yes) into that row .. Use OFFSET to insert it into the correct column.
5. When deleting.. Again. use vlookup to determine the selections row position and then delete the row.

I would also be making a function where you can also add new workers to your data range via the Userform.
 
Upvote 0

Forum statistics

Threads
1,214,859
Messages
6,121,963
Members
449,059
Latest member
oculus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top