Thread: Find Data
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Find Data

Please don't multi post between the discussion groups... Most people
answering question monitor all of the groups.

Sub TestCopy()
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim rngPaste As Range
Dim strFirst As String

Set rngToSearch = Sheets("Sheet1").Columns("A")
Set rngFound = rngToSearch.Find(What:=16, _
LookAt:=xlWhole, _
LookIn:=xlValues)
Set rngPaste = Sheets("Schedule Counts").Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)
If rngFound Is Nothing Then
MsgBox "sorry... nothing to copy"
Else
strFirst = rngFound.Address
Set rngFoundAll = rngFound
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirst
rngFoundAll.EntireRow.Copy Destination:=rngPaste
End If

End Sub

--
HTH...

Jim Thomlinson


"Stan" wrote:

I have VB code that creates the data below by using subtotals but I need to
find data in column A (7760) and copy and paste the data in another tab
(Schedule Counts). In other words, search for '7760' in column A and cut and
paste the row where '7760' exists. In the example below, I need to copy and
paste A2:C4.

I appreciate any help.

Column A Column B Column C
1) 7750 6:00am 11
2) 7760 6:00am 9
3) 7760 6:15am 13
4) 7760 6:45am 4
5) 7765 7:00am 6