I have a form with a combobox, that is tied to a range on a worksheet. The range can have multiple duplicate values. When a user selects a value from a drop down box, I'd like them to see only 1 of the possible values, and have the data presented tied to the max date of the Update Date. Essentially, if the worksheet has 5 entries where the name = "Tom" and the Update Date is 5/1/17, 6/1/17, 7/8/17, 8/1/17, 10/1/17, I want the User to only see one instance of Tom in the combo box (along with the other names in there), and the data presented in the rest of the form to be tied to the record from 10/1/17.
I've searched this, and other sites, and haven't found anything that makes sense to me. That's probably b/c I'm still new to VBA, and trying to piece things together.
I've searched this, and other sites, and haven't found anything that makes sense to me. That's probably b/c I'm still new to VBA, and trying to piece things together.
Code:
Private Sub cmd_Submit_Click()
Dim ws1 As Worksheet
Set ws1 = ThisWorkbook.Sheets("Client Measurements")
LastRow = ws1.Range("C" & Rows.Count).End(xlUp).Row + 1
ws1.Range("B" & LastRow) = Me.txt_Updated
ws1.Range("C" & LastRow) = Me.txt_First
ws1.Range("D" & LastRow) = Me.txt_Last
ws1.Range("E" & LastRow) = Me.txt_Suffix
ws1.Range("F" & LastRow) = Me.cobo_Name
ws1.Range("G" & LastRow) = Me.txt_EntryType
ws1.Range("H" & LastRow) = Me.txt_Height
ws1.Range("I" & LastRow) = Me.txt_Weight
ws1.Range("J" & LastRow) = Me.txt_Chest
ws1.Range("K" & LastRow) = Me.txt_Hips
ws1.Range("L" & LastRow) = Me.txt_Waist
ws1.Range("M" & LastRow) = Me.txt_BicepL
ws1.Range("N" & LastRow) = Me.txt_BicepR
ws1.Range("O" & LastRow) = Me.txt_ThighL
ws1.Range("P" & LastRow) = Me.txt_ThighR
ws1.Range("Q" & LastRow) = Me.txt_CalfL
ws1.Range("R" & LastRow) = Me.txt_CalfR
End Sub
Private Sub cobo_Name_DropButt*******()
Dim i As Long
Dim coll As Collection
Dim ws1 As Worksheet
Set ws1 = ThisWorkbook.Sheets("Client Measurements")
LastRow = Sheets("Client Measurements").Range("F" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Sheets("Client Measurements").Cells(i, "F").Value = (Me.cobo_Name) Or _
Sheets("Client Measurements").Cells(i, "F").Value = Val(Me.cobo_Name) Then
Me.txt_First = Sheets("Client Measurements").Cells(i, "C").Value
Me.txt_Last = Sheets("Client Measurements").Cells(i, "D").Value
Me.txt_Suffix = Sheets("Client Measurements").Cells(i, "E").Value
Me.txt_Height = Sheets("Client Measurements").Cells(i, "H").Value
Me.txt_Weight = Sheets("Client Measurements").Cells(i, "I").Value
Me.txt_Chest = Sheets("Client Measurements").Cells(i, "J").Value
Me.txt_Hips = Sheets("Client Measurements").Cells(i, "K").Value
Me.txt_Waist = Sheets("Client Measurements").Cells(i, "L").Value
Me.txt_BicepL = Sheets("Client Measurements").Cells(i, "M").Value
Me.txt_BicepR = Sheets("Client Measurements").Cells(i, "N").Value
Me.txt_ThighL = Sheets("Client Measurements").Cells(i, "O").Value
Me.txt_ThighR = Sheets("Client Measurements").Cells(i, "P").Value
Me.txt_CalfL = Sheets("Client Measurements").Cells(i, "Q").Value
Me.txt_CalfR = Sheets("Client Measurements").Cells(i, "R").Value
End If
Next
End Sub
Private Sub UserForm_Initialize()
Dim ws1 As Worksheet
Dim cCMName As Range
Set ws1 = ThisWorkbook.Sheets("Client Measurements")
For Each cCMName In ws1.Range("CMName")
With Me.cobo_Name
.AddItem cCMName.Value
End With
Next cCMName
txt_EntryType = "Check In"
End Sub