Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help: Matching two columns/strings of data

Status
Not open for further replies.

Cartwheel

Technical User
Mar 14, 2002
13
US
Hiya!

I'm a newbie! I have four columns of data:

number1 label1 number2 label2

the label have the same values, but different numbers assigned to them. I am trying to take each sequential number1/label1 combination, paste it into the next row, find the same matching string in label 2, cut and paste number2/label2 in the same row as number1/label1. So the output would be:

number1 label1 number2 label2 (which would be the same as label1).

Basically, I'm trying to match two columns long lists of data.

So far, what I have just returns the same string intstead of going to the next row/string:

Sub Matching4()
'
' Matching4 Macro
'

'
Application.CommandBars("Stop Recording").Visible = True
ActiveCell.Offset(26, 0).Range("A1:B1").Select
ActiveCell.Offset(26, 1).Range("A1").Activate
Selection.Copy
ActiveCell.Offset(-26, -1).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Cells.Find(What:="ADP-ribosylation factor 2", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False).Activate
Cells.FindNext(After:=ActiveCell).Activate
ActiveCell.Offset(0, -1).Range("A1:B1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveWindow.LargeScroll Down:=-1
Range("C288").Select
ActiveWindow.LargeScroll Down:=-1
Range("C268").Select
ActiveWindow.LargeScroll Down:=-1
Range("C248").Select
ActiveWindow.LargeScroll Down:=-1
Range("C228").Select
ActiveWindow.LargeScroll Down:=-1
Range("C208").Select
ActiveWindow.LargeScroll Down:=-1
Range("C188").Select
ActiveWindow.LargeScroll Down:=-1
Range("C168").Select
ActiveWindow.LargeScroll Down:=-1
Range("C148").Select
ActiveWindow.LargeScroll Down:=-1
Range("C128").Select
ActiveWindow.LargeScroll Down:=-1
Range("C108").Select
ActiveWindow.LargeScroll Down:=-1
Range("C88").Select
ActiveWindow.LargeScroll Down:=-1
Range("C68").Select
ActiveWindow.LargeScroll Down:=-1
Range("C48").Select
ActiveWindow.LargeScroll Down:=-1
Range("C18").Select
ActiveSheet.Paste
Rows("3:3").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
End Sub
 
Have you tried nested for next loops (2 to be exact)
1 for steping down your source column the other for steping down the column that you are trying to match against.

That with a couple of copy and paste commands should give you all you need.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top