gpt4 book ai didi

vba - 在特定工作表中搜索文本字符串

转载 作者:行者123 更新时间:2023-12-04 21:54:31 24 4
gpt4 key购买 nike

我试图让 excel 在不是事件工作表的特定工作表的特定列中搜索文本字符串。 VBA 给我一个错误,说我不能使用这种选择方法。所以我的问题是,你有建议以另一种方式来做吗?

Worksheets("Parts for renovation").Columns("Q:Q").Select
Set cell = Selection.Find(What:="Total transfer price", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

If cell Is Nothing Then

Exit Sub

Else

Worksheets("Internal").Cells(29, 4) = Worksheets("Parts for Renovation").ActiveCell.Offset(0, 4)

End If

最佳答案

那里不需要选择任何东西:

With Worksheets("Parts for renovation").Columns("Q:Q")
Set cell = .Find(What:="Total transfer price", After:=.Cells(1), LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If cell Is Nothing Then
Exit Sub
Else
Worksheets("Internal").Cells(29, 4) = Cell.Offset(0, 4)
End If
End With

关于vba - 在特定工作表中搜索文本字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47634511/

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