Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Find All and then Copy the Data...

I have a sheet setup that is a list of people who have signed things out from our office. It includes date/timestamp information, user IDs, and items borrowed

I want a way to put someone's ID in a box and have it then do a search and if it finds that ID in the list, it would Copy the whole row (just to make it easier) onto a new Sheet. This I can do

However, I then want it to continue through the sheet looking for more instances of the text and to continue to copy the data for all rows where it finds the person's ID. Basically to pull a history for the user and see what they have checked out and when

How would I do the command (or loop) to repeat the search until it hits the end of the data

Can I somehow put a set VAR = cells.find... inside of a loop and say Search, copy data, search again, until it doesn't find it

Any guidance would be great


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Find All and then Copy the Data...

Try this example
http://www.rondebruin.nl/copy5.htm

Post back if you need more help


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Mr B" wrote in message ...
I have a sheet setup that is a list of people who have signed things out from our office. It includes date/timestamp information,

user IDs, and items borrowed.

I want a way to put someone's ID in a box and have it then do a search and if it finds that ID in the list, it would Copy the

whole row (just to make it easier) onto a new Sheet. This I can do.

However, I then want it to continue through the sheet looking for more instances of the text and to continue to copy the data for

all rows where it finds the person's ID. Basically to pull a history for the user and see what they have checked out and when.

How would I do the command (or loop) to repeat the search until it hits the end of the data?

Can I somehow put a set VAR = cells.find... inside of a loop and say Search, copy data, search again, until it doesn't find it?

Any guidance would be great.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Find All and then Copy the Data...

Hi Mr B

With WS.Range("YourRange")
'Use a Dynamic range name, http://www.contextures.com/xlNames01.html#Dynamic
'This example filter on the first column in the range (change the field if needed)


This is the range you filter
For example WS.Range("A1:G100")
<Look at the link for using a Dynamic range name


.AutoFilter Field:=1, Criteria1:=Str


It will filter on the first column for the text in the string.
Str = "Netherlands"
You filter in column A in this example


Set WSNew = Sheets.Add
.Cells.SpecialCells(xlCellTypeVisible).Copy WSNew.Range("A1")
End With


It will add a new sheet to the workbook and copy all the visible cells.
All the cells with Netherlands in column A to that sheet



WS.AutoFilterMode = False


Show all the data


On Error Resume Next
WSNew.Name = Str
If Err.Number 0 Then
MsgBox "Change the name of : " & WSNew.Name & " manually"
Err.Clear
End If
On Error GoTo 0
End Sub


Give the sheet you add a name(name of the Str )



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Mr B" wrote in message ...
I'm assuming this is the code part that does most of the work. I'm not familiar with these commands so could you break it down

for me?

With WS.Range("YourRange")
'Use a Dynamic range name, http://www.contextures.com/xlNames01.html#Dynamic
'This example filter on the first column in the range (change the field if needed)
.AutoFilter Field:=1, Criteria1:=Str
Set WSNew = Sheets.Add
.Cells.SpecialCells(xlCellTypeVisible).Copy WSNew.Range("A1")
End With



Also what does the rest of this do?

WS.AutoFilterMode = False
On Error Resume Next
WSNew.Name = Str
If Err.Number 0 Then
MsgBox "Change the name of : " & WSNew.Name & " manually"
Err.Clear
End If
On Error GoTo 0
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and copy data between () Ty Excel Discussion (Misc queries) 4 October 20th 09 09:07 PM
Find and copy data kiml Excel Worksheet Functions 3 April 29th 08 01:15 PM
find last row and copy previous row data Woodi2 Excel Worksheet Functions 1 February 18th 08 11:24 PM
Find & Copy Data query bbibib Excel Discussion (Misc queries) 3 February 9th 06 06:35 PM
Can Excel Find and Copy a row of data? Still Learning Excel Worksheet Functions 0 September 20th 05 10:06 PM


All times are GMT +1. The time now is 03:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"