I want to find the corresponding Disc Codes from a list and copy them in the DiscName column in the summary sheet. some lab names will have more than one Disc codes so when I run the macro it should bring up all the relevant Disc Codes matching with the Lab name to DiscName column. Any help will be greatly appreciated. Not sure if I can upload the image of the summary sheet but i looks like this.
Col 1 col 2 col 3
Lab name Disc Name
(say abcd) xxxx
yyyy
zzzz
pppp
and the list looks something like this.
Col 1 Col 2
Lab name Disc name
abcd xxxxx
abcd yyyyy
abcd zzzzz
abcd ppppp
bcda qqqqq
bcda rrrrr
bcda iiiii
bcda jjjjj
bcda kkkkk
I just re arranged the table so it looks more clearer. Hope this helps to understand my query better. Thanks again for any help.
I tried this code but I cannot get it to write the next Disc name in the next row after under Disc name in the summary sheet. It repeats the same Disc name as the first one. Ideally it should continue to fill in the Summary sheet with all the relevant Disc Names appearing agianst the Lab name in the list.
Sub Vlooker()
Dim FindString As String Dim Rng As Range Dim fcomp For Each fcomp In Sheets("cont").Range("p3") ' range of Source Comparison
FindString = fcomp
With Sheets("list").Range("q2:q106") 'range of cells to search
Set Rng = .Find(What:=FindString, _
After:=.Cells(1), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False)
If Rng Is Nothing Then
Else
Do While fcomp = FindString
fcomp.Offset(0, 1).Value = Rng.Offset(0, 1)
fcomp.Offset(1, 1).Value = Rng.Offset(0, 1)
Loop
End If
End With
Next fcomp
End Sub
This is what I want to happen real symple terms.
Go to List, Check A2.
If list A2 matches with Summary A2 then
go to summary b2
make summary b2 value = to list b2 value
then chekc next row in list
if found match with summary a2 then
go to summary, last actioned cell, go one row down and make value = to the value in column b in list against the matching cell
Repeat this process till all matches found for summary a2.
Start this process when ever value of summay a2 changes.
.Find
method in a loop. Or you could use the range.AutoFilter
method on the list sheet, and then iterate over the visible cells (SpecialCells(xlCellTypeVisible)
)? Or you could just build an array in memory and print/transpose that out to the worksheet? There's several ways to approach this problem. What have you tried so far? – David Zemens