Hi, first time poster hear. I've read many of the posts and there are so many different ways to accomplish what I'm trying to do but being a novice at VBA I'm not sure if this is the best method. It also doesn't seem to be working 100% but I don't understand why.
In any event, I have a userform that has the displays rows from Sheet1. These rows can be selected from a listbox which then shows the "details" of what they've selected (otherwise the fields are blank and they can add a new record). When they select an existing record my userform shows the existing data - the issue comes in when they try to save/update that data. Below is the code I'm using:
Private Sub cmdOkay_Click()
n = Application.Match(Me.ListBox1.Value, Range("A:A"), 0)
Cells(n, 2).Value = Me.txtSiteName.Text
Cells(n, 3).Value = Me.txtAddress.Text
Cells(n, 4).Value = Me.txtCity.Text
Cells(n, 5).Value = Me.txtState.Text
Cells(n, 6).Value = Me.txtZip.Text
Cells(n, 7).Value = Me.txtMailcode.Text
Cells(n, 8).Value = Me.txtCompletedBy.Text
Cells(n, 9).Value = Me.txtPD.Text
Cells(n, 10).Value = Me.txtPDPhone.Text
Cells(n, 11).Value = Me.txtFloors.Text
Cells(n, 12).Value = Me.txtCurbside.Text
Cells(n, 13).Value = Me.txt13.Text
Cells(n, 14).Value = Me.txt14.Text
Cells(n, 15).Value = Me.txt15.Text
Cells(n, 16).Value = Me.txt16.Text
Cells(n, 17).Value = Me.txt17.Text
Cells(n, 18).Value = Me.txt18.Text
Cells(n, 19).Value = Me.txt19.Text
Cells(n, 20).Value = Me.txt20.Text
Cells(n, 21).Value = Me.txt21.Text
Cells(n, 22).Value = Me.txt22.Text
Cells(n, 23).Value = Me.txt23.Text
Cells(n, 24).Value = Me.txt24.Text
Cells(n, 25).Value = Me.txt25.Text
Cells(n, 26).Value = Me.txt26.Text
Cells(n, 27).Value = Me.txt27.Text
Cells(n, 28).Value = Me.txt28.Text
End Sub
The first record "txtSiteName" updates but none of the others do. What I would like is for it to search for that record, make all of the updates (in a single row). If it isn't found I would like for it to add a new record. Each row has a unique ID (that is in column A) that I need created when it saves (haven't worked on the Add New button yet so I'm not there yet
)
Again, thanks for any assistance.
Bookmarks