ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   to delete row from userform (https://www.excelbanter.com/excel-programming/324968-delete-row-userform.html)

Alen32

to delete row from userform
 
I have userform with one combobox which contain products name stored in
cells a2:a50(named My List) when I choose one Macro delete row where
product name is. I want to have one command button on userform which do
this. What I need to change in this code:

Option Explicit
Public Cleared As Boolean

Private Sub ComboBox1_Change()
Dim i As Integer
If Not Cleared Then
With Sheets(1)
i = Application.Match(Me.ComboBox1.Value, Range("MyList"), 0)
Cleared = True
.Range("MyList")(i).EntireRow.Delete Shift:=xlUp

End With
End If
Cleared = False
Me.Hide
End Sub




Bob Phillips[_6_]

to delete row from userform
 
Change this

.Range("MyList")(i).EntireRow.Delete Shift:=xlUp

to

.Range("MyList").Cells(i,1).EntireRow.Delete Shift:=xlUp

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alen32" wrote in message
lkaboutsoftware.com...
I have userform with one combobox which contain products name stored in
cells a2:a50(named My List) when I choose one Macro delete row where
product name is. I want to have one command button on userform which do
this. What I need to change in this code:

Option Explicit
Public Cleared As Boolean

Private Sub ComboBox1_Change()
Dim i As Integer
If Not Cleared Then
With Sheets(1)
i = Application.Match(Me.ComboBox1.Value, Range("MyList"), 0)
Cleared = True
.Range("MyList")(i).EntireRow.Delete Shift:=xlUp

End With
End If
Cleared = False
Me.Hide
End Sub







All times are GMT +1. The time now is 07:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com