View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
merjet merjet is offline
external usenet poster
 
Posts: 812
Default Read values from an Excel Table?

"Excel Table" is not very specific. Assuming it refers to a Range on a
worksheet other than the active one, you could do something like the
following. Such Range likely should not be on the ActiveSheet since
the code deletes rows.

Sub Test()
Dim bFlag As Boolean
Dim c As Range
Dim rng As Range

y = ActiveSheet.Range("A1").End(xlDown).Row
EndRow = y
Set rng = Sheets("Sheet2").Range("A1:A5")
For y = 1 To EndRow
Cells(y, 1).Select
bFlag = False
For Each c In rng
If Cells(y, 1).Value Like c Then
bFlag = True
End If
Next c
If bFlag = True Then
y = y + 1
Else
Cells(y, 1).Select
Selection.Delete Shift:=xlUp
If ActiveCell.Row 1 Then
ActiveCell.Offset(-1, 0).Select
End If
End If
Next
End Sub

Hth,
Merjet