#4
|
|||
|
|||
I found the solution to my question at the URL below:
http://www.mrexcel.com/forum/excel-q...worksheet.html It works well for my needs. Here's the code: Sub Test2() Dim myWord$ myWord = InputBox("What key word to copy rows", "Enter your word") If myWord = "" Then Exit Sub Application.ScreenUpdating = False Dim xRow&, NextRow&, LastRow& NextRow = 2 LastRow = Cells.Find(What:="*", After:=Range("A1"), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row For xRow = 1 To LastRow If WorksheetFunction.CountIf(Rows(xRow), "*" & myWord & "*") > 0 Then Rows(xRow).Copy Sheets("Sheet2").Rows(NextRow) NextRow = NextRow + 1 End If Next xRow Application.ScreenUpdating = True MsgBox "Macro is complete, " & NextRow - 2 & " rows containing" & vbCrLf & _ "''" & myWord & "''" & " were copied to Sheet2.", 64, "Done" End Sub |
Tags |
vba code |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Trying to find a macro that will copy a cell and paste that value to a specific sheet | bryans88 | Excel Programming | 1 | 12-23-2015 01:40 PM |
Populate sheet 3 with data from sheet 1 and sheet 2 | speck | Excel Programming | 0 | 01-14-2015 07:54 AM |
matching data from one work sheet to another, then auto filling missing cell information | timomaha | Excel | 1 | 09-12-2014 07:51 AM |
Find Results in excel copy the rows to another sheet | khalidfazeli | Excel | 2 | 02-06-2013 09:38 AM |
copy cell from sheet 2 to sheet 3 macro | slipperyjim | Excel Programming | 1 | 02-18-2010 01:31 AM |