Delete a row

R

Rhonda

Hi,

I was wondering if anyone could provide me with a
function for a command button that when clicked, will
prompt the user for the row number they want to delete
and then delete it for them. Or if this is not possible,
something similar would also be great!!

Thanks for your help!
 
C

Chip Pearson

Rhonda,

Use code like the following:

Dim RowNdx As Long
RowNdx = Application.InputBox(prompt:="Enter a row number",
Type:=1)
If RowNdx > 0 And RowNdx <= Rows.Count Then
Rows(RowNdx).Delete
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
R

Rhonda

Thank you very much!!! That's great!!

-----Original Message-----
Rhonda,

Use code like the following:

Dim RowNdx As Long
RowNdx = Application.InputBox(prompt:="Enter a row number",
Type:=1)
If RowNdx > 0 And RowNdx <= Rows.Count Then
Rows(RowNdx).Delete
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com






.
 
Top