我有两个工作表,在第二个工作表中我已经定义了所有参数的唯一名称
在第一张表格中,我已经定义了参数名称,单击“自动填充按钮”,我希望它去检查缩略图表中的所有参数名称,如果找到匹配项,则应该替换特定参数& #39;唯一身份证。
有谁能告诉我如何使用excel VBA实现这一点,任何帮助表示赞赏!
答案 0 :(得分:0)
循环通过一个找到另一个。
Sub DoIt()
Dim sh As Worksheet, ws As Worksheet
Dim LstRw As Long, rng As Range, c As Range, Frng As Range
Set sh = Sheets("Sheet1") 'Acronym Sheet
Set ws = Sheets("Sheet2")
With sh
LstRw = .Cells(.Rows.Count, "B").End(xlUp).Row
Set rng = .Range("B2:B" & LstRw)
End With
With ws
For Each c In rng.Cells
Set Frng = .Range("C:C").Find(what:=c, lookat:=xlWhole)
If Not Frng Is Nothing Then
Frng.Value = c.Offset(, -1).Value
Else:
End If
Next c
End With
End Sub