dpaton05
Well-known Member
- Joined
- Aug 14, 2018
- Messages
- 2,352
- Office Version
- 365
- 2016
- Platform
- Windows
I have a worksheet that has a dynamic list of names in column A on the sheet with the code name YP. The list starts in A3 and can have names added to it. I have a listbox called lboTracker on the sheet with the code name Tracker as is populated with the list of names. I want to be able to click on a name in the list box then select a button to delete it from the list. Could someone show me how would I do this please?
I have this code so far
I have this code so far
VBA Code:
Option Explicit
Sub OpenFile()
Dim SelectedItem As String
SelectedItem = Cells(1, 1).Value
Workbooks.Open Filename:=ThisWorkbook.Path & "\Young People\" & SelectedItem & ".xlsm"
End Sub
Sub AddYP()
Dim NewYP As String
NewYP = Tracker.Cells(5, 4)
YP.Range("A" & Rows.Count).End(xlUp).Offset(1, 0) = NewYP
End Sub
Sub PopLB()
Dim Lastrow As Long
Lastrow = YP.Cells(Rows.Count, "A").End(xlUp).Row
Tracker.lboYP.List = YP.Range("A2:A" & Lastrow).Value
End Sub
Sub Sort()
Range("A2", Range("A2").End(xlDown)).Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlNo
End Sub