Delete non-contiguous selected rows
One way:
Copy the FUNCTION below into a standard code module. Call the following
function from your code like this:
Sub Test()
'your code
Call DeleteSelectedRows
'your other code
End Sub
Private Function DeleteSelectedRows()
'DELETE ENTIRE ROW FOR EACH ROW IN CURRENT SELECTION
Dim laRows() As String
Dim rRow As Range
Dim lX As Long
For Each rRow In Selection.Rows
lX = lX + 1
ReDim Preserve laRows(lX)
laRows(lX) = rRow.EntireRow.Address
Next rRow
For lX = UBound(laRows) To 1 Step -1
Range(laRows(lX)).EntireRow.Delete
Next lX
End Function
HTH
"Barbara Ryan" wrote:
I need to be able to delete rows (via VBA) that a user selects on a
worksheet. The rows can be non-contiguous. I have seen several examples to
delete non-contiguous rows based on a cell value, but not for non-contiguous
selected rows. Any suggestions???
Thanks,
Barb Ryan
|