#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Excel

How can I search a column for specific values and have all rows that contain
these values copied to another sheet?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Excel

Hi,

Not too much infor but here's a macro that will do it. It looks in Column A.
Change the string to search for and the source and destination sheets to suit

Sub stance()
Dim MyRange As Range
Dim CopyRange As Range
Dim MyString As String
Dim SrcSht As String
Dim DestSht As String
Dim LastRow As Long
MyString = "XXX" ' change to suit must be in uppercase
SrcSht = "Sheet1" ' change to suit
DestSht = "Sheet2" ' change to suit
LastRow = Sheets(SrcSht).Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Sheets(SrcSht).Range("A1:A" & LastRow)
For Each c In MyRange

If UCase(c.Value) = MyString Then
If CopyRange Is Nothing Then
Set CopyRange = c.EntireRow
Else
Set CopyRange = Union(CopyRange, c.EntireRow)
End If
End If
Next
If Not CopyRange Is Nothing Then
CopyRange.Copy Destination:=Sheets(DestSht).Range("A1")
End If
End Sub


Mike

"Bhameo" wrote:

How can I search a column for specific values and have all rows that contain
these values copied to another sheet?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Excel

DataFilterAutofilter.

F5SpecialVisible cells only.

Copypaste to other sheet.


Gord Dibben MS Excel MVP

On Tue, 12 Jan 2010 12:33:01 -0800, Bhameo
wrote:

How can I search a column for specific values and have all rows that contain
these values copied to another sheet?


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



All times are GMT +1. The time now is 02:39 AM.

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

About Us

"It's about Microsoft Excel"