I am trying to populate a Userform with data from a spreadsheet "Welfare Listing" with up to 200 names in a range "F2:F201"
I wish to copy the found data in the searched row using the find system and using the current row of the worksheet("Welfare Listing" vba code TextBox18.Value = (Sheets("Welfare Listing").Cells(CurrentRow, "f").Value)
If I replace the (current row) for the numerical value of the row that the cursor is located then I am able to get the desired result, but when I run my macro it always seems to give me the result that is determined by the current row of the Worksheet("Data Entry") which is the name of the sheet that the Userform is displayed in.
I am trying to find a name on Worksheet("Welfare Listing") and use this name to search for the CurrentRow.value of the name and by using this value I am then able to populate the data to the UserForm which is activated by selecting the Worksheet("Data Entry")
Could someone please help.
The Vba code that have written is shown below.
Private Sub CommandButton8_Click()
Dim Today
Today = Now ' Assign current system date and time.
'MsgBox "current row" & ActiveCell.Row
Dim CurrentRow
Dim MyDate
CurrentRow = ActiveCell.Row
MyDate = Date ' MyDate contains the current system date.
Dim WL As Long, MS As Long, MR As Long, lrWL As Long
lrWL = Sheets("Welfare Listing").Range("S" & Rows.Count).End(xlUp).Row
TextBox23.Value = Left(Sheets("Welfare Listing").Cells(CurrentRow, "S").Value, 4)
TextBox34.Value = Right(Sheets("Welfare Listing").Cells(CurrentRow, "S").Value, 4)
TextBox24.Value = Left(Sheets("Welfare Listing").Cells(CurrentRow, "U").Value, 4)
TextBox35.Value = Mid(Sheets("Welfare Listing").Cells(CurrentRow, "U").Value, 6, 3)
TextBox36.Value = Right(Sheets("Welfare Listing").Cells(CurrentRow, "U").Value, 3)
TextBox18.Value = (Sheets("Welfare Listing").Cells(CurrentRow, "f").Value)
End Sub
Thank you in advance