View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] jaydywan@gmail.com is offline
external usenet poster
 
Posts: 13
Default Refer to cell in diff sheet

I have the following below, and I want If (cell.value) = "1034" to
refer to cell G2 in worksheet entitled "menu." How would I write
that, so it refers to the value in that cell. Thanks.

Sub Delete_Rows()
' This macro deletes all rows on the active worksheet
' that have 1034, 1035, 1037 column E.
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("E:E"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) = "1034" _
Or (cell.Value) = "1035" _
Or (cell.Value) = "1037" Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next
On Error Resume Next
del.EntireRow.Delete
End Sub