Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
BC BC is offline
external usenet poster
 
Posts: 26
Default Multiple search and copy

I am looking to find instances of words within a url that is in a column.
Then select the rows that contain any words from a list and then copy those
selected rows to a second sheet.

I would like to be able to add words and use regular expressions for some
words.

EG
I would like to find the following
Chat
Face*
Bebo*
Any help would be most appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Multiple search and copy

Sub finddate()
SearchCol = "A"

words = Array("Chat", "Face*", "Bebo*")

With Sheets("Sheet1")
For Each phrase In words

If Right(phrase, 1) = "*" Then

Set c = Columns(SearchCol & ":" & SearchCol). _
Find(what:=phrase, LookIn:=xlValues, _
lookat:=xlPart)
Else
Set c = Columns(SearchCol & ":" & SearchCol). _
Find(what:=phrase, LookIn:=xlValues, _
lookat:=xlWhole)
End If
If Not c Is Nothing Then
With Sheets("Sheet2")
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
c.EntireRow.Copy _
Destination:=.Rows(LastRow)
End With
End If
Next phrase
End With

End Sub


"BC" wrote:

I am looking to find instances of words within a url that is in a column.
Then select the rows that contain any words from a list and then copy those
selected rows to a second sheet.

I would like to be able to add words and use regular expressions for some
words.

EG
I would like to find the following
Chat
Face*
Bebo*
Any help would be most appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
BC BC is offline
external usenet poster
 
Posts: 26
Default Multiple search and copy

Joel

The only thing I have changed in your code was the column and the words
which did not work.

The columns I have are
WKS ID Date Time Proxy Site

The code below I was using works to an extent but only on single words and
it ends with an error but it does copy selected rows to Sheet2.

Sub test()
Dim FilterValue As String
Dim rng As Range
Dim rng2 As Range

Set rng = Range("F:F")
FilterValue = "*sports*"

rng.AutoFilter Field:=1, Criteria1:=FilterValue
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng2 = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng2 Is Nothing Then
rng2.EntireRow.Copy Sheets("Sheet2").Range("A1")
End If
End With
ActiveSheet.AutoFilterMode = False
End Sub

This is new to me and I am still trying to get my head round it.

Thanks very much.




"Joel" wrote:

Sub finddate()
SearchCol = "A"

words = Array("Chat", "Face*", "Bebo*")

With Sheets("Sheet1")
For Each phrase In words

If Right(phrase, 1) = "*" Then

Set c = Columns(SearchCol & ":" & SearchCol). _
Find(what:=phrase, LookIn:=xlValues, _
lookat:=xlPart)
Else
Set c = Columns(SearchCol & ":" & SearchCol). _
Find(what:=phrase, LookIn:=xlValues, _
lookat:=xlWhole)
End If
If Not c Is Nothing Then
With Sheets("Sheet2")
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
c.EntireRow.Copy _
Destination:=.Rows(LastRow)
End With
End If
Next phrase
End With

End Sub


"BC" wrote:

I am looking to find instances of words within a url that is in a column.
Then select the rows that contain any words from a list and then copy those
selected rows to a second sheet.

I would like to be able to add words and use regular expressions for some
words.

EG
I would like to find the following
Chat
Face*
Bebo*
Any help would be most appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Multiple search and copy

try this to autofilter each and copy to next row in other sheet. Bypasses
"donald"

Sub findinurl()
myarray = Array("CHAT", "donald", "with", "Me")
mycol = "a"
destsheet = "sheet16"
lr = Cells(Rows.Count, mycol).End(xlUp).Row
On Error Resume Next
For Each c In myarray
Range("A1").AutoFilter Field:=1, Criteria1:="=*" & c & "*"
With Sheets(destsheet)
dlr = .Cells(Rows.Count, "a").End(xlUp).Row + 1
Range("A2:A" & lr).SpecialCells(xlCellTypeVisible).Copy _
Sheets("Sheet16").Range("A" & dlr)
End With
Next c
Range("a1").AutoFilter
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"BC" wrote in message
...
I am looking to find instances of words within a url that is in a column.
Then select the rows that contain any words from a list and then copy
those
selected rows to a second sheet.

I would like to be able to add words and use regular expressions for some
words.

EG
I would like to find the following
Chat
Face*
Bebo*
Any help would be most appreciated.


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
Multiple column search and Copy Sklyn Excel Worksheet Functions 7 October 9th 09 04:53 AM
search, copy and paste through multiple sheets Jeff S.[_2_] Excel Discussion (Misc queries) 1 August 16th 09 12:08 AM
Looping: Search Range in Multiple Selected Worksheets, Copy/Paste ryguy7272 Excel Programming 6 April 2nd 07 04:50 PM
How do I search excel spreadsheets using multiple search criteria. Kasper Excel Worksheet Functions 4 December 15th 05 12:26 AM
multiple search criteria to find and copy from sheet1 and paste into sheet2 lothario[_54_] Excel Programming 2 November 25th 03 09:57 AM


All times are GMT +1. The time now is 01:52 AM.

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"