Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 788
Default Find and copy across multi-sheet work book

Is there a way to look at a cell in sheet1 and then search the entire
workbook for a match, then if a match is found, copy that entire row over the
source row in sheet1.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Find and copy across multi-sheet work book

Here is some code to try. It looks a cell A2 in sheet 1 and searches the rest
of the sheets for that value. If it find it then it replaces the row in sheet
1 with the found row. It then goes on to cell A3 (next cell down) in sheet 1
and does the same thing again until it runs into an empty cell in row A of
sheet 1.

Sub FindAndReplace()
Dim wksMain As Worksheet
Dim wksCurrent As Worksheet
Dim rngToFind As Range
Dim rngFound As Range

Set wksMain = Sheets("Sheet1")
Set rngToFind = wksMain.Range("A2")

Do Until rngToFind.Value = Empty
For Each wksCurrent In Worksheets
If wksCurrent.Name < wksMain.Name Then
Set rngFound = wksCurrent.Cells.Find(rngToFind.Value)
If Not rngFound Is Nothing Then
rngFound.EntireRow.Copy rngToFind
Exit For
End If
End If
Next wksCurrent
Set rngToFind = rngToFind.Offset(1, 0)
Loop

End Sub
--
HTH...

Jim Thomlinson


"chris" wrote:

Is there a way to look at a cell in sheet1 and then search the entire
workbook for a match, then if a match is found, copy that entire row over the
source row in sheet1.

Reply
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
how do i copy a worksheet to another work book multi work book sheet copies Excel Worksheet Functions 1 July 15th 08 08:38 PM
multi pages in work book jason2444 Excel Discussion (Misc queries) 2 September 19th 06 01:44 PM
Viewing Multi-worksheets in same work-book allieh Excel Worksheet Functions 3 February 16th 06 12:22 PM
Moving a sheet from one work book to another? WTG Excel Worksheet Functions 1 November 3rd 05 07:12 PM
Is there away to keep "auto save" from jumping to the first work sheet in the work book? Marc New Users to Excel 2 April 21st 05 01:27 AM


All times are GMT +1. The time now is 04:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"