我想从列表中找到相应的光盘代码并将它们复制到摘要表的 DiscName 列中。一些实验室名称将有多个光盘代码,因此当我运行宏时,它应该将与实验室名称匹配的所有相关光盘代码显示到 DiscName 列。
不确定我是否可以上传摘要表的图像,但它看起来像这样。
Col 1 col 2 col 3
Lab name Disc Name
(say abcd) xxxx
yyyy
zzzz
pppp
列表看起来像这样。
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
我只是重新安排了桌子,使它看起来更清晰。
我尝试了此代码,但无法让它在摘要表中的光盘名称下的下一行中写入下一个光盘名称。它重复与第一个相同的光盘名称。理想情况下,它应该继续填写摘要表,其中所有相关的光盘名称都出现在列表中的实验室名称旁边。
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
这是我想要发生的真正简单的术语。
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.