gpt4 book ai didi

excel - 查找在用户窗体中键入的值的行和列

转载 作者:行者123 更新时间:2023-12-04 22:02:36 24 4
gpt4 key购买 nike

我有一个用户表单供用户将他们的 ID 号键入一个表中。但是我怎样才能捕获表中id的行数和列数并删除它们。

Set f = Worksheets("data").Range("4:4").Find(What:=TextBox2.Value)

If Worksheets("data").Cells(f.Row, f.Column).Value = TextBox2.Value Then
Worksheets("data").TextBox2.Value.Delete
End If

非常感谢您

最佳答案

Find()返回找到的单元格:如果没有匹配,则返回 Nothing .

只要Find()找到匹配项,然后您可以直接使用它:无需提取 f.Rowf.Column然后将它们转回相同的范围。即fWorksheets("data").Cells(f.Row, f.Column)引用同一个对象。

Set f = Worksheets("data").Range("4:4").Find(What:=TextBox2.Value, lookat:=xlWhole)

If Not f Is Nothing Then
f.Delete
End If

关于excel - 查找在用户窗体中键入的值的行和列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32102057/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com