Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 03-19-2016, 01:41 PM
Auto Auto is offline Find matching criterior in sheet 1 and copy to Sheet 2 Windows 8 Find matching criterior in sheet 1 and copy to Sheet 2 Office 2007
Novice
Find matching criterior in sheet 1 and copy to Sheet 2
 
Join Date: Mar 2016
Posts: 9
Auto is on a distinguished road
Default

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
Reply With Quote
 

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
Find matching criterior in sheet 1 and copy to Sheet 2 matching data from one work sheet to another, then auto filling missing cell information timomaha Excel 1 09-12-2014 07:51 AM
Find matching criterior in sheet 1 and copy to Sheet 2 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

Other Forums: Access Forums

All times are GMT -7. The time now is 01:48 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft