Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Copy Rows if Cell F? contains

My sheet has 200+ rows of data in columns A - P. I want to search the text in
column F cells for 'myString' and copy those rows in another worksheet, same
workbook. Row A is a header row.

Your assistance is greatly appreciated as always.

Hal
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copy Rows if Cell F? contains

Dim rng as Range
Dim rw as Long
Dim cell as Range
set rng = range(cells(2,6),cells(rows.count,6).End(xlup))
rw = 2
for each cell in rng
if instr(1,cell,"myString",vbTextCompare) then
Cells(cell.row,1).Resize(1,16).copy _
Destination:=Worksheets("Sheet2").Cells(rw,1)
rw = rw + 1
end if
Next

--
Regards,
Tom Ogilvy

"Hal" wrote in message
...
My sheet has 200+ rows of data in columns A - P. I want to search the text

in
column F cells for 'myString' and copy those rows in another worksheet,

same
workbook. Row A is a header row.

Your assistance is greatly appreciated as always.

Hal



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Copy Rows if Cell F? contains

Hi Hal,

Try something like:

'================
Public Sub CopyRange()
Dim Rng As Range
Dim rCell As Range
Dim copyRng As Range
Dim destRng As Range
Dim WB As Workbook
Dim SH As Worksheet
Dim LRow As Long
Dim CalcMode As Long
Const sStr As String = '"ABCD" '<<==== CHANGE

Set WB = ActiveWorkbook '<<==== CHANGE
Set SH = WB.Sheets("Sheet1") '<<==== CHANGE
Set destRng = WB.Sheets("Sheet2").Range("A2") '<<==== CHANGE

LRow = Cells(Rows.Count, "A").End(xlUp).Row

Set Rng = SH.Range("F2:F" & LRow)

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

For Each rCell In Rng.Cells
If InStr(1, rCell, sStr, vbTextCompare) 0 Then
If copyRng Is Nothing Then
Set copyRng = rCell
Else
Set copyRng = Union(rCell, copyRng)
End If
End If
Next rCell

If Not copyRng Is Nothing Then
copyRng.EntireRow.Copy Destination:=destRng
Else
'nothing found, do nothing
End If

With Application
.Calculation = CalcMode
.ScreenUpdating = True
End With

End Sub
'<<================


---
Regards,
Norman



"Hal" wrote in message
...
My sheet has 200+ rows of data in columns A - P. I want to search the text
in
column F cells for 'myString' and copy those rows in another worksheet,
same
workbook. Row A is a header row.

Your assistance is greatly appreciated as always.

Hal



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
Copy Rows with a cell value 0 from several worksheets to a new sh Skeletor Excel Worksheet Functions 1 October 6th 08 09:37 PM
Copy Rows with a cell value 0 from several worksheets to a new sh Skeletor Excel Worksheet Functions 5 October 1st 08 02:46 AM
Copy same cell formula in many rows... Dennis1188 Excel Discussion (Misc queries) 0 March 8th 07 07:29 PM
How to copy data in one cell into different rows catchxan Excel Worksheet Functions 1 November 28th 05 01:25 AM
select copy rows where a cell contains a known emmsy9 Excel Programming 0 September 4th 05 02:49 PM


All times are GMT +1. The time now is 09:53 PM.

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"