Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default text search between workbooks, copy data

I have a workbook titled “data comparison” that contains sample i
numbers in column B ( example: Sample1, Sample10, sample32 etc.).
I would like to write code that opens a second workbook title
“results”, searches column A of that workbook for the matching sampl
ID (ex. Sample32), then copies data in the row with the matching sampl
ID and pastes the data back into the first workbook (data comparison).
Specifically, I am having trouble with the search method between tw
workbooks. Any tips would be helpful. Thank

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default text search between workbooks, copy data

When dealing with two separate workbooks, you'll need to specify the
workbook in the code. I suggest creating two Workbook variables and using
them throughout. For example:

dim CompareWB as Workbook
dim ResultsWB as Workbook
dim SampleID as string
dim rFind as Range

set CompareWB=Workbooks("data comparison.xls")
set ResultsWB = Workbooks("results.xls")

rowcount = CompareWB.Worksheets(1).UsedRange.Rows.Count
for row = 1 to rowcount
SampleID = CompareWB.Worksheets(1).Cells(row,2).Value
set rFind = ResultsWB.Worksheets(1).Columns(1).Find(What:=Samp leID,
LookAt:=xlWhole)
if not rFind is Nothing then
ResultsWB.Worksheets(1).Cells(rFind.Row,
2).Copy(CompareWB.Worksheets(1).Cells(row,3))
endif
next row

"G8834 " wrote in message
...
I have a workbook titled "data comparison" that contains sample id
numbers in column B ( example: Sample1, Sample10, sample32 etc.).
I would like to write code that opens a second workbook titled
"results", searches column A of that workbook for the matching sample
ID (ex. Sample32), then copies data in the row with the matching sample
ID and pastes the data back into the first workbook (data comparison).
Specifically, I am having trouble with the search method between two
workbooks. Any tips would be helpful. Thanks


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



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
search text in other workbooks jtaiariol Excel Worksheet Functions 0 July 8th 08 05:25 PM
search and copy text from one sheet to others simpsonehh Excel Worksheet Functions 4 April 21st 08 11:05 PM
Copy/ move selected data from workbooks to seperate worksheets or workbooks Positive Excel Worksheet Functions 1 August 30th 07 04:54 PM
Search and copy certain text Rusty Excel Discussion (Misc queries) 2 July 20th 06 12:11 AM
SEARCH COPY OF TEXT LinzNac Excel Discussion (Misc queries) 1 February 10th 05 12:39 AM


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

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

About Us

"It's about Microsoft Excel"