Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Matching rows in 2 sheets and copying matching rows from sheet 1 t

I've got 2 sheets in the same workbook - A and B.
Sheet B is a new unvalidated list of customers, sheet A is the validated
list of customers. Each sheet has a column with customer number.

I need to go through all customer numbers in Sheet B, and for each customer
number to go to Sheet A to see if there is a match. If there is a match, then
copy the whole row of the matching number from sheet A, and paste it to the
matching row of sheet B (it should be converted to uppercase before pasting).

Can you help me with macro ? Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Matching rows in 2 sheets and copying matching rows from sheet 1 t

You will need to change the sheet names or index numbers if
they are not, in fact, A and B. The sheet to be copied from
should be the active sheet when the procedure runs.

Sub cpynpstUC()
Worksheets("A").Activate
Dim rng As Range
lstRw = Worksheets("B").Cells(Rows.Count, 1).End(xlUp).Row
lstCol = Worksheets("A").Cells(2, Columns.Count).End(xlToLeft).Column
Set bRng = Sheets("B").Range("$A$2:$A" & lstRw) 'Assumes Header Row
Set aRng = Sheets("A").Range("$A$2:$A" & Cells(Rows.Count, 1).End(xlUp).Row)
For Each c In bRng
If Not c Is Nothing Then
x = c.Address
For Each i In aRng
If Not i Is Nothing Then
y = i.Address
If c.Value = i.Value Then
Range(y).EntireRow.Copy Sheets("B").Range(x)
Set convRng = Sheets("B").Range(x & ":IV" & Range(x).Row)
For Each rng In convRng
If rng.HasFormula = False Then
rng.Value = UCase(rng.Value)
End If
Next
End If
End If
Next i
End If
Next c
End Sub

"fbagirov" wrote:

I've got 2 sheets in the same workbook - A and B.
Sheet B is a new unvalidated list of customers, sheet A is the validated
list of customers. Each sheet has a column with customer number.

I need to go through all customer numbers in Sheet B, and for each customer
number to go to Sheet A to see if there is a match. If there is a match, then
copy the whole row of the matching number from sheet A, and paste it to the
matching row of sheet B (it should be converted to uppercase before pasting).

Can you help me with macro ? Thanks!

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
Matching Columns in work sheets and copying both rows to new Shelley68 Excel Discussion (Misc queries) 1 March 19th 10 07:09 PM
copy matching value rows to other sheet tkraju via OfficeKB.com Excel Discussion (Misc queries) 2 June 7th 09 12:41 PM
Can I merge data in 2 sheets matching rows of data by last name? Corb Excel Discussion (Misc queries) 1 March 18th 07 05:32 PM
Help on Matching and Copying Values In Two Different Sheets sylink Excel Programming 2 June 2nd 06 05:43 PM
Matching data rows from two different sheets into a new a new one Jean-Jérôme Doucet via OfficeKB.com Excel Programming 1 June 14th 05 08:08 PM


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