Update Information with Multi Select List Box

aroig07

New Member
Joined
Feb 26, 2019
Messages
42
Hi all !!!

I am just starting off with VBA and have made a couple of userforms, but ran into a question when trying to update the information based on multiple selections in a ListBox. I have a userform that shows in a list box all of the jobs that are due this week, if for some reason I do not receive the materials I want to change the status to pending. I had a combo box previously which updated the pertinent information, but going one by one was taking a long time and I decided to change to ListBox thinking the code would be the same but it is not working. The macro runs without debuging but it does not update the column to "Pending".

Here is my code as of now:

Private Sub CommandButton4_Click()


'Click to update the status of the jobs in the master job trail to say they are pending
g = 1
Do
DoEvents
g = g + 1
p = Sheets("Master Job Trail").Range("A" & g)


If p = ListBox1.Text Then
Sheets("Master Job Trail").Range("S" & g) = TextBox6.Text
End If


Loop Until p = ""


MsgBox "Worked was added as pending", vbInformation
ThisWorkbook.Save


Unload Pending


End Sub
 
By JobName which is a combination of text and numbers in order to update the status to Pending on each of the jobs that are selected in the list box.
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Which line is giving the error?
 
Upvote 0
Set Fnd = ws.Range("A:A").Find(.List(i), , xlWhole, , , False, , False)

Here is the entire code I have copied:

Private Sub CommandButton4_Click()


Dim i As Long
Dim Fnd As Range
Dim ws As Worksheet


Set ws = Sheets("Master Job Trail")
With Me.ListBox1
For i = 2 To .ListCount - 1
If .Selected(i) Then
Set Fnd = ws.Range("A:A").Find(.List(i), , xlWhole, , , False, , False)
If Not Fnd Is Nothing Then Fnd.Offset(, 19).Value = Me.TextBox6
End If
Next i
End With

MsgBox "Trabajo fue añadido a los trabajos que están pendientes", vbInformation
ThisWorkbook.Save

End Sub
 
Upvote 0
You're missing a comma, it should be
Code:
         Set Fnd = ws.Range("A:A").Find(.List(i), , , xlWhole, , , False, , False)
Also it should be
Code:
For i = [COLOR=#b22222]0[/COLOR] To .ListCount - 1
otherwise it will ignore the first 2 items in the listbox
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,978
Members
448,934
Latest member
audette89

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