I am new in Excel VBA and I am trying to make a user-form that must do the following.
We are using a excel spreadsheet that gets updated monthly. from that name list (PICKLIST) we then on a regular basis search by number and then we make other name lists with the data that is linked to the force number that we have searched for.
I have made the user form (as attch file) and all is working. I got the code sorted to search for the first record and it populates the user form. when I use a number other than the first number in the ws then it does not populate the user form.
I got it to send that data to the bottom of the PICKLIST but that is not what i want. I want the information to be send to a ws named DATA. There is ±480 records on the PICKLIST ws.

Included is the code as I have it at present.
PLEASE I NEED HELP!!!!!!!!
Greetings
Dawid


__________________________________________________________________
We are using a excel spreadsheet that gets updated monthly. from that name list (PICKLIST) we then on a regular basis search by number and then we make other name lists with the data that is linked to the force number that we have searched for.
I have made the user form (as attch file) and all is working. I got the code sorted to search for the first record and it populates the user form. when I use a number other than the first number in the ws then it does not populate the user form.
I got it to send that data to the bottom of the PICKLIST but that is not what i want. I want the information to be send to a ws named DATA. There is ±480 records on the PICKLIST ws.



Included is the code as I have it at present.
Code:
Private Sub cmdClose_Click()
'WHEN CLOSE BUTTEN IS CLICKED THE USERFORM CLOSES WITH EXELL SPREADSHEET VISABLE
Unload Me
End Sub
Private Sub cmdSearch_Click()
'SEARCH THE ACTIVE WORKSHEET WITH FORCE NO TO POPULATE THE DATA SEARCH FORM
txtForceNo.Text = Range("B8").Value
txtAC.Text = Range("C8").Value
txtRank.Text = Range("D8").Value
txtInI.Text = Range("E8").Value
txtSurname.Text = Range("F8").Value
txtCorps.Text = Range("G8").Value
txtRSAID.Text = Range("H8").Value
txtRace.Text = Range("I8").Value
txtGender.Text = Range("J8").Value
txtFormerForce.Text = Range("K8").Value
txtRemarks.Text = Range("L8").Value
End Sub
Private Sub cmdSendTo_Click()
'DATA THAT WAS POPULATED IN THE DATA SEARCH FORM WILL NOW BE SEND TO THE DATA SHEET
Range("B8").Select
'FIND OUT HOW MANY ROWS ON THE SPREADSHEET HAS BEEN USED
ActiveCell.End(xlDown).Select
lastrow = ActiveCell.Row
'MsgBox lastrow GET THE NUMBER OF THE LAST ROW USED LAST ROW TO BE SHOWN ON THE MESSAGE BOX
Cells(lastrow + 1, 2).Value = txtForceNo.Text
Cells(lastrow + 1, 3).Value = txtAC.Text
Cells(lastrow + 1, 4).Value = txtRank.Text
Cells(lastrow + 1, 5).Value = txtInI.Text
Cells(lastrow + 1, 6).Value = txtSurname.Text
Cells(lastrow + 1, 7).Value = txtCorps.Text
Cells(lastrow + 1, 8).Value = txtRSAID.Text
Cells(lastrow + 1, 9).Value = txtRace.Text
Cells(lastrow + 1, 10).Value = txtGender.Text
Cells(lastrow + 1, 11).Value = txtFormerForce.Text
Cells(lastrow + 1, 12).Value = txtRemarks.Text
'CLEAR ALL FIELDS OF DATA FORM ONCE DATA HAS BEEN TRANSFERRED
Range("B8").Select
txtForceNo.Text = ""
txtAC.Text = "' "
txtRank.Text = ""
txtInI.Text = ""
txtSurname.Text = ""
txtCorps.Text = ""
txtRSAID.Text = ""
txtRace.Text = ""
txtGender.Text = ""
txtFormerForce.Text = ""
txtRemarks.Text = ""
End Sub
Private Sub UserForm_Click()
End Sub
Greetings
Dawid


__________________________________________________________________
Mod edit : thread moved to appropriate forum !
Last edited by a moderator: