Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,090
Default Excel VBA

This macro should do what you want. I assumed the following:
Your data starts in row 2 in Column A of the first sheet.
The copied data goes into Column G of the first sheet.
The second sheet is named "Second".
The code searches for the values in Column A of the first sheet.
The code searches IN Column A of the second sheet.
If found, the value in Column G of the second sheet is copied and pasted to
the first sheet.
HTH Otto
Sub CopyData()
Dim RngColAFirst As Range
Dim RngColASecond As Range
Dim i As Range
Set RngColAFirst = _
Range("A2", Range("A" & Rows.Count).End(xlUp))
With Sheets("Second")
Set RngColASecond = _
.Range("A2", .Range("A" & Rows.Count).End(xlUp))
For Each i In RngColAFirst
If Not RngColASecond.Find(What:=i.Value, _
LookAt:=xlWhole) Is Nothing Then
RngColASecond.Find(What:=i.Value, _
LookAt:=xlWhole).Offset(, 6).Copy _
i.Offset(, 6)
End If
Next i
End With
End Sub


"Mr. Clean" wrote in message
...
I'd like to start at the first row and step through each row of the first
sheet. The worksheet has 300 rows, so I'd like to automate the process.
The value should be at the end of the row selected.

"Otto Moehrbach" wrote:

How is the first cell selected? For instance, does the user select a
cell
and then run the macro?
Where in the first sheet do you want the value placed that came from the
second sheet? HTH Otto
"Mr. Clean" <Mr. wrote in message
...
I need to write a VBA program (or a macro) that will select a cell from
a
worksheet, then look for the same text in a cell in another worksheet
(in
the
same workbook), then copy another cell in the row that the text is
found,
then paste it in the first worksheet.






 
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
Stop excel from dropping the 0 in the beginning of a number? Rosewood Setting up and Configuration of Excel 12 April 4th 23 02:12 PM
Open Excel 2003 from Windows Explorer pmpjr Excel Discussion (Misc queries) 9 September 11th 06 03:58 PM
Need suggestions for some uses of Ms Excel Bible John Excel Discussion (Misc queries) 1 February 27th 06 05:30 PM
Excel Range Value issue (Excel 97 Vs Excel 2003) Keeno Excel Discussion (Misc queries) 2 June 13th 05 02:01 PM
Excel 2002 and 2000 co-install. Control Which Starts ? cnuk Excel Discussion (Misc queries) 2 January 17th 05 08:07 PM


All times are GMT +1. The time now is 03:40 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"