我如何去一个细胞改变价值?

我已经做了一些“更改”button,需要去在Vlookup中find的单元格,如下所示。

我只能find符合给定范围的代码。

Private Sub CommandButton6_Click() Dim status As Variant status = WorksheetFunction.VLookup( _ (Sheets("Gegevens").Range("B3")), _ Sheets("bestand totaal").Range("J2:W9996"), 14, False) End Sub 

通过VLookup查找status ,可以使用“ Findfunctionsearch发现该值的VLookup范围。

我已经添加了2个Rangevariables, Rng范围的RngFindRngFind

 Private Sub CommandButton6_Click() Dim status As Variant Dim Rng As Range Dim RngFind As Range Set Rng = Sheets("bestand totaal").Range("J2:W9996") status = WorksheetFunction.VLookup((Sheets("Gegevens").Range("B3").Value), Rng, 14, False) Set RngFind = Rng.Find(What:=status, LookIn:=xlValues, Lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True) RngFind.Parent.Activate ' activate the worksheet, in case the VLookup Range is not the active sheet RngFind.Select ' select the range (cell) where Find was set to true End Sub 

也许你是在这之后

 Private Sub CommandButton6_Click() Dim status As Variant status = Application.Match(Sheets("Gegevens").Range("B3"), _ Sheets("bestand totaal").Range("J2:J9996"), False) '<--| try and get the index of 'Sheets("Gegevens").Range("B3")' value in 'Sheets("bestand totaal").Range("J2:J9996")' range If Not IsError(status) Then '<--| if value successfully found With Sheets("bestand totaal") '<--| reference "target" sheet .Activate '<--| activate it .Range("W2:W9996").Cells(status, 1).Select <--| select corresponding value in column "W" End With End If End Sub