T
TheGodfather
i have the code :
Private Sub UserForm_activate()
Dim myRng As Range
Dim myCell As Range
With Worksheets("sheet1")
Set myRng = .Range("C2", .Cells(.Rows.Count, "C").End(xlUp))
End With
With Me.ctrlList
For Each myCell In myRng.Cells
.AddItem myCell.Text
Next myCell
End With
'Me.ctrlList.Clear
End Sub
Private Sub DeleteButton_Click()
Dim i As Integer
If Not Cleared Then
With Sheets("Sheet1")
i = Application.Match(Me.ctrlList.Value, Range("C:C"), 0)
Cleared = True
.Range("C:C" & i).EntireRow.Delete Shift:=xlUp
End With
End If
Cleared = False
Me.Hide
End Sub
and i am having 2 problems, the values on the list box regenerate only
when i restart the form not automaticaly eventhough i need to
regenerate when ever i have a new record and the deleting code is not
working , i wanted to be assigned to the list box, whenever i click a
value on the list box and press the delet button , the whole row
having this value shall be deleted from the excel worksheet could you
please help?
i appreciate your help
Private Sub UserForm_activate()
Dim myRng As Range
Dim myCell As Range
With Worksheets("sheet1")
Set myRng = .Range("C2", .Cells(.Rows.Count, "C").End(xlUp))
End With
With Me.ctrlList
For Each myCell In myRng.Cells
.AddItem myCell.Text
Next myCell
End With
'Me.ctrlList.Clear
End Sub
Private Sub DeleteButton_Click()
Dim i As Integer
If Not Cleared Then
With Sheets("Sheet1")
i = Application.Match(Me.ctrlList.Value, Range("C:C"), 0)
Cleared = True
.Range("C:C" & i).EntireRow.Delete Shift:=xlUp
End With
End If
Cleared = False
Me.Hide
End Sub
and i am having 2 problems, the values on the list box regenerate only
when i restart the form not automaticaly eventhough i need to
regenerate when ever i have a new record and the deleting code is not
working , i wanted to be assigned to the list box, whenever i click a
value on the list box and press the delet button , the whole row
having this value shall be deleted from the excel worksheet could you
please help?
i appreciate your help