A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hi,
Thanks for Reply.....
when execute code,, Error comes as run time Error "9", Subscript of out of Range
In the sample workbook, you gave us sheets are named Sheet1 and Sheet2 as shown in the picture below.
So if on the original workbook the sheets are named differently, you must adapt the code, and change the names of the sheets (highlighted in RED) accordingly.
So if Sheet1="Data Entry" and Sheet2="Records"
then
''''''******************************************************************
Sub DeleteMyRows()
Dim s As String
Dim RowArr() As String
Dim i As Long
s = Sheets("Data Entry").Range("I7").Value
''To split the comma separated rows
RowArr = Split(s, ",")
Application.ScreenUpdating = False
''' To delete rows we need to do it from the bottom since they shift up.
For i = UBound(RowArr) To LBound(RowArr) Step -1
Sheets("Records").Range("A" & RowArr(i)).EntireRow.Delete
Next i
Application.ScreenUpdating = True
MsgBox "Job done"
End Sub
'''''*********************************************************
Notes:
If you want to use the command button to execute the macro then
Use the code
Private Sub CommandButton1_Click()
Call DeleteMyRows
End Sub
OR
Private Sub CommandButton1_Click()
Dim s As String
Dim RowArr() As String
Dim i As Long
s = Sheets("Data Entry").Range("I7").Value
''To split the comma separated rows
RowArr = Split(s, ",")
Application.ScreenUpdating = False
''' To delete rows we need to do it from the bottom since they shift up.
For i = UBound(RowArr) To LBound(RowArr) Step -1
Sheets("Records").Range("A" & RowArr(i)).EntireRow.Delete
Next i
Application.ScreenUpdating = True
MsgBox "Job done"
End Sub
Anyways
Here is the link to your file with the code and answer to your question
Regards
Jeovany