VBA help needed ~ lookup/insert

unit213

Active Member
Joined
Jul 11, 2003
Messages
427
Hey guys...

I need some VBA help. I'm not sure how difficult this will be, but it's way out of my league for now unfortunately.

Here's a sample spreadsheet:
Index Match Example.xls
ABCD
1ShoeShoeColor
2NikeNikeWhite
3ReebokReebokGray
4NewBalanceNewBalanceBlue
5NikeBlue
6ReebokRed
7ReebokGreen
8NewBalanceWhite
Sheet1


Here's the challenge:

Lookup the values in column A. Locate them in colum B. Find the corresponding value in column C. Take the value found in column C and insert it below the correct value in column A.

Example of completed spreadsheet:
Index Match Example.xls
ABCD
12Shoe
13Nike
14White
15Blue
16Reebok
17Gray
18Red
19Green
20NewBalance
21Blue
22White
Sheet1


Can anyone offer up some help? Much appreciated as always. Thanks. (y)

Dan
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
If I understand what you're after, this code seems to work. Dave
Code:
Private Sub CommandButton1_Click()
Dim Rng As Range, Rng2 As Range, rng3 As Range
Dim i As Integer, Cnt As Integer, Counter As Integer
'row1 is title
'Matches "A" with "B". Enters match name "B" only once...
'2 rows below last "A" then adds "C" values of A/B match
'to next "A" row
Set Rng2 = Range("a2:a" & Range("a2").End(xlDown).Row)
Set Rng = Range("B2:B" & Range("B2").End(xlDown).Row)
'use to clear "A" of previous results
Range("a65536:a" & Range("a2").End(xlDown).Row + 1).ClearContents
Counter = 1
For Cnt = 2 To Rng2.Rows.Count + 1
off = 0
For i = 2 To Rng.Rows.Count + 1
If Cells(Cnt, 1) = Cells(i, 2) Then
If off = 0 Then
Counter = Counter + 1
Cells(Rng2.Rows.Count + 1 + Counter, 1) = Cells(i, 2)
off = 1
End If
Counter = Counter + 1
Cells(Rng2.Rows.Count + 1 + Counter, 1) = Cells(i, 3)
End If
Next i
Next Cnt
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,462
Messages
6,055,563
Members
444,799
Latest member
CraigCrowhurst

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top