ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto find a specific row and copy it to another worksheet (https://www.excelbanter.com/excel-programming/315395-auto-find-specific-row-copy-another-worksheet.html)

hme

Auto find a specific row and copy it to another worksheet
 

Hi

let me explain more clear

how can excel find automatically a given text in all worksheets (i
there is any) of a given workbook and copy the row where this text i
to another worksheet.

should be easy but I can't :mad:

sohrab hashem

--
hm
-----------------------------------------------------------------------
hme's Profile: http://www.excelforum.com/member.php...fo&userid=1593
View this thread: http://www.excelforum.com/showthread.php?threadid=27415


Tom Ogilvy

Auto find a specific row and copy it to another worksheet
 
Assume we will copy to Sheet2 (so don't search that sheet)


Sub CopyInfo()
Dim sh as Worksheet, rng as Range
for each sh in worksheets
if lcase(sh.name) < "sheet2" then
set rng = sh.Cells.Find("textString")
if not rng is nothing then
rng.EntireRow.copy Destination:= _
worksheets("Sheet2").Cells(rows.count,1).End(xlup) (2)
exit sub
end if
end if
Next
msgbox "TextString not found"
End Sub

Find has many arguments which correspond to choices in the Edit=Find
dialog. Some of these arguments are persistent and could affect the outcome
of the find command. It is usually safer to specify them all explicitely.
You can turn on the macro recorder and do an Edit=Find to get code that
shows how to set them all and then look in the Excel VBA help file for an
explanation of each along with alternate values for the arguments.

--
Regards,
Tom Ogilvy




"hme" wrote in message
...

Hi

let me explain more clear

how can excel find automatically a given text in all worksheets (if
there is any) of a given workbook and copy the row where this text is
to another worksheet.

should be easy but I can't :mad:

sohrab hashemi


--
hme
------------------------------------------------------------------------
hme's Profile:

http://www.excelforum.com/member.php...o&userid=15930
View this thread: http://www.excelforum.com/showthread...hreadid=274152





All times are GMT +1. The time now is 04:55 AM.

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