View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Andoni[_9_] Andoni[_9_] is offline
external usenet poster
 
Posts: 1
Default Locate all occurrances of a value then transfer to 2nd table on another sheet

Try this!

Sub Andoni()
Dim Looked_Value As Variant
Dim C As Range
Dim First_Address As Variant
With Sheets(1)
'This Sheet contain the first Table and the Desired Value
'Range("S4").Value
.Visible = True
.Activate
Looked_Value = .Range("S4").Value
End With
Application.ScreenUpdating = False
With Worksheets(1).Cells 'Put any other range (such a
Range("A1:C14"))
Set C = .Find(Looked_Value, LookIn:=xlValues)
If Not C Is Nothing Then
First_Address = C.Address
Do
Sheets(2).Range(C.Address).Value = Looked_Value
'Sheets(2).Range(First_Address).Select
Set C = .FindNext(C)
Loop While Not C Is Nothing And C.Address < First_Address
Sheets(2).Range("S4").Value = ""
End If
End Wit

--
Message posted from http://www.ExcelForum.com