ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Lookup Macro Trouble (https://www.excelbanter.com/excel-programming/309262-lookup-macro-trouble.html)

JennF

Lookup Macro Trouble
 
Can you create a macro that will lookup a text string within the
spreadsheet, and if true copy that entire row to another spreadsheet
within the workbook?


---
Message posted from http://www.ExcelForum.com/


Frank Kabel

Lookup Macro Trouble
 
Hi
see:
http://www.rondebruin.nl/copy5.htm

--
Regards
Frank Kabel
Frankfurt, Germany


Can you create a macro that will lookup a text string within the
spreadsheet, and if true copy that entire row to another spreadsheet
within the workbook?


---
Message posted from http://www.ExcelForum.com/


Nick Hodge

Lookup Macro Trouble
 
Jenn

The following is some starter code. It uses my Sheet1 (lookup sheet),
Sheet2 (Copy sheet). It will place the found row below the last one in the
copy sheet. (Presuming row 1 is headers)

It does no error checking past the searched item is found

Sub findAndMove()
Dim sData As String
Dim rFindRange As Range
Dim lLastRow As Long
sData = InputBox("Enter search string")
If Worksheets("Sheet1").Cells.Find(sData, , , xlWhole) Is Nothing Then
MsgBox "Search string not found", vbOKOnly
Exit Sub
End If
lLastRow = Worksheets("Sheet2").Range("A65536").End(xlUp).Row + 1
Set rFindRange = Worksheets("Sheet1").Cells.Find(sData, , , xlWhole)
rFindRange.EntireRow.Copy Destination:=Worksheets("Sheet2").Range("A" &
lLastRow)
End Sub


--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"JennF " wrote in message
...
Can you create a macro that will lookup a text string within the
spreadsheet, and if true copy that entire row to another spreadsheet
within the workbook?


---
Message posted from
http://www.ExcelForum.com/





All times are GMT +1. The time now is 10:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com