It appears you have the code in a worksheet module. If so, when you have a Range call that is unqualified by a worksheet, it actually refers to the range on the worksheet containing the code, and since that sheet is not active, you cannot select a range on it. However, you don't need to select anything here anyway:
Private Sub CommandButton1_Click()
Dim rng As Range
Dim del As Range
Dim cell As Range
Dim strCellValue As String
Dim wks as Worksheet
Set wks = Sheets("Sheet1")
Sheets("Sheet2").Range("B2:D170").Copy Destination:=wks.Range("B2")
Set rng = Intersect(wks.Range("D2:D170"), wks.UsedRange)
For Each cell In rng
strCellValue = (cell.Value)
If InStr(strCellValue, "0") = 1 Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next cell
On Error Resume Next
del.EntireRow.Delete
End Sub
Bookmarks