View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Sinner Sinner is offline
external usenet poster
 
Posts: 142
Default Deleting rows with 11+ characters.

On Mar 31, 6:51 pm, JE McGimpsey wrote:
One way:

No need to trim that I can see.

Dim vArr As Variant
Dim rCell As Range
Dim rDelete As Range
Dim nLow As Long
Dim nHigh As Long
Dim i As Long
Dim sTest As String

With Sheets("Sheet1")
vArr = .Range(.Cells(1, 1), _
.Cells(.Rows.Count, 1).End(xlUp)).Value
End With
nLow = LBound(vArr, 1)
nHigh = UBound(vArr, 1)
With Sheets("Sheet2")
For Each rCell In .Range(.Cells(1, 1), _
.Cells(.Rows.Count, 1).End(xlUp))
sTest = rCell.Text
For i = nLow To nHigh
If sTest = vArr(i, 1) Then
If rDelete Is Nothing Then
Set rDelete = rCell
Else
Set rDelete = Union(rDelete, rCell)
End If
End If
Next i
Next rCell
If Not rDelete Is Nothing Then rDelete.EntireRow.Delete
End With

In article .com,



"Sinner" wrote:
I have the following code for deleting pins found in a list in
"column
1" of "sheet1" from list in "column 1" of "sheet 2" with the list
tagged in other columns, leaving behind updated & reconciled dataset
in sheet 2.- Hide quoted text -


- Show quoted text -


Dear Joel & JE McGimpsey,

Thank you for your replies.

JE McGimpsey I want to reuse the same sheet with another set of data.
I have added

Sub Clear()

Sheets(Array("Sheet1", "Sheet2")).Select
Sheets("Sheet1").Activate
Cells.Select
Selection.Clear
Sheets("Sheet2").Select
Range("A1").Select
Sheets("Sheet1").Select
Range("A1").Select

End Sub


Clear is assigned to a clear button & your script to another button.
I get a run time error after I clear the sheet with above & reuse your
script.

Any idea??