LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copy/Paste rows with specifc text in column d


I posted this to the wrong group yesterday. My apologies, I'm new to this.

I'm trying to write a macro that will bring up a text box to ask the user
what he/she is looking for (always text). The macro then looks through a
monster sheet of 7000 rows and copies every row that contains the text
string in column D, then deposits the rows into a new sheet. The
text string being searched for is a short piece within a longer string (ie.
'review' within 'project review').

This is what I have so far...I have not been able to copy/paste the row when
I get a hit.

Private Sub Copy_Paste_Rows_w_Match()
Dim ws As Worksheet
Dim targetws As Worksheet
Dim cl As Range, ctextalues As String, tRow As Long
Dim myvalue As String
Dim myrow As Range

If ActiveWorkbook Is Nothing Then Exit Sub

On Error Resume Next
If targetws Is Nothing Then
Set ws = ActiveSheet
Set SourceWB = ActiveWorkbook
Set targetws = Worksheets.Add.Worksheets(1)
Set targetws = ActiveSheet
SourceWB.Activate
ws.Activate
Set SourceWB = Nothing
End If

myvalue = InputBox("Find what?")

Set ws = ActiveSheet
For Each cl In ws.Range("D6:D7000").SpecialCells(xlConstants,
xlTextValues).Cells
ctextvalues = cl
If Len(ctextvalues) 0 Then

If InStr(cl, myvalue) 1 Then ctextvalues =
myrow.targetws.Activate.Cells.Range("A1") = myrow.ws.Activate
' This is where I am stuck. I have not been able to
copy/paste the row when I get a hit.
End If

Set cl = Nothing
End Sub


 
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
Macro to hide rows with zero in specifc column range David Excel Discussion (Misc queries) 1 April 20th 10 08:10 PM
summing specifc state abbreviations in a column Kathy S New Users to Excel 2 May 29th 09 04:09 PM
A macro to copy & paste many rows (a range) to the next column .. genehunter New Users to Excel 11 April 21st 09 07:36 AM
Copy/Paste Rows that Contain Specific Text Mike Woodard Excel Worksheet Functions 1 March 8th 06 07:35 PM
Hide Rows - copy and paste only rows that show Access101 Excel Worksheet Functions 3 March 1st 06 12:39 AM


All times are GMT +1. The time now is 03:03 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"