Excel 宏根据第一个 sheet 中的特定单元格值在不同的作品中添加单元格值sheet

Excel macro add a cell value in a different worksheet based on a specific cell value in the first sheet

Click here to see the picture

嗨,我需要有人帮我在我的 Excel 2007 年做这个场景:)

场景是这样的:

单击 commandButton1 后

所以每当我输入另一个代码,例如 QZ0822 (sheet1),然后在我点击按钮后,它会自动在包含 QZ0822 (sheet2) 的单元格旁边添加“确定”。

我可以这样做吗?

是这样的吗?

Sub lookup()
    Dim strSearch As String
    Dim wks1 As Worksheet
    Dim wks2 As Worksheet

    Set wks1 = Sheets("Your Sheet 1") '<--- fill in your sheet name
    Set wks2 = Sheets("Your Sheet 2") '<--- fill in your sheet name

    strSearch = wks1.Range("B3").Value

    With wks2
        .Columns(2).Find(strSearch).Offset(0, 1).Value = "Ok"
    End With
End Sub