【问题标题】:How to Find the data in another worksheet and place replace the corresponding value using excel VBA如何在另一个工作表中查找数据并使用excel VBA替换相应的值
【发布时间】:2016-03-13 02:29:20
【问题描述】:

我有两个工作表,在第二个工作表中我定义了所有参数的唯一名称

在第一张表中,我只定义了参数名称,单击“自动填充”按钮,我希望它去检查 Acronym 表中的所有参数名称,如果找到匹配项,它应该替换特定参数的唯一身份。

谁能告诉我如何使用 excel VBA 实现这一点,感谢任何帮助!

【问题讨论】:

  • Unique id 表示首字母缩写词,(抱歉没有指定)
  • 您想将 C 列中的每个“类型”更改为“Insul”...和“标准”->“IEC”/“版本”->“ver”......。我说的对吗?

标签: vba excel worksheet


【解决方案1】:

遍历一个以找到另一个。

    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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-06
    • 1970-01-01
    • 2023-04-06
    • 2016-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-07
    相关资源
    最近更新 更多