WelshyWizard
IS-IT--Management
I've the following code which updates a listbox when moving from cell to cell (depending upon a value)...
What I want to do is to clear the listbox when moving from a cell, ready for the new values to be entered.
Anyone have any ideas? I tried to use removeallitems with no success.
Cheers
Today is the tomorrow you worried about yesterday - and all is well.....
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Get the current row position and the value from the 2nd column in
'that row.
ListBox1_Populate ActiveCell.Top, Cells(ActiveCell.Row, 2).Value
End Sub
Private Sub ListBox1_Populate(NewTop As Long, Optional ContractNumber As String)
Dim wksLookup As Worksheet
Set wksLookup = Worksheets("PHASING")
celval = 5
Do
If wksLookup.Range("C" & celval) = ContractNumber Then
ListBox1.AddItem wksLookup.Range("A" & celval) & " " & Format(wksLookup.Range("B" & celval) & "'%", "")
celval = celval + 1
Else
celval = celval + 1
End If
Loop Until wksLookup.Range("C" & celval) = ""
End Sub
What I want to do is to clear the listbox when moving from a cell, ready for the new values to be entered.
Anyone have any ideas? I tried to use removeallitems with no success.
Cheers
Today is the tomorrow you worried about yesterday - and all is well.....