sách gpt4 ai đã đi

excel - InStr 值数组(可能?)

In lại 作者:行者123 更新时间:2023-12-04 21:15:29 40 4
mua khóa gpt4 Nike

Private Sub Workbook_Open()

Dim WBname As String
WBname = ThisWorkbook.name

If Not InStr(WBname, "test") > 0 Then
MsgBox ("NotOK")
End If

End Sub

biên tập:更多说明。

我现在测试工作簿名称中是否包含“Test”。

但我想测试工作簿名称中是否有比“测试”更多的单词,而无需复制粘贴代码一千次。

1 Câu trả lời

nếu như WBname 必须包含所有单词,则使用此选项

Dim WBname As String
WBname = ThisWorkbook.Name

Dim arrWords As Variant, aWord As Variant
arrWords = Array("aa", "bb", "cc") 'input your words list here

For Each aWord In arrWords
If Not InStr(WBname, aWord) > 0 Then
MsgBox ("NotOK")
Exit For
End If
Next

nếu như WBname 必须至少包含一个词,则使用此选项

Dim WBname As String
WBname = ThisWorkbook.Name

Dim arrWords As Variant, aWord As Variant
arrWords = Array("aa", "bb", "cc") 'input your words list here

Dim wordFound As Boolean
wordFound = False
For Each aWord In arrWords
If InStr(WBname, aWord) > 0 Then
wordFound = True
Exit For
End If
Next
If Not wordFound Then
MsgBox ("NotOK")
End If

关于excel - InStr 值数组(可能?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43784022/

40 4 0
Bài viết được đề xuất: excel - countif 和 weeknum
Bài viết được đề xuất: ruby-on-rails - 禁用 Mailchimp 双重选择加入
Bài viết được đề xuất: SpringSource 包存储库更改
Bài viết được đề xuất: vba - VBA 宏运行时关闭 "everything"
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com