gpt4 book ai didi

excel - 检查范围内的每个单元格是否有特定字符串?

转载 作者:行者123 更新时间:2023-12-03 03:42:30 24 4
gpt4 key购买 nike

我想要一个 VBA 代码,通过它我可以检查具有特定文本的范围内的每个单元格?

EG: for each cell in range (a:a)
if value of cell = "specific text"
do this
else
do that

*

如何在 VBA Excel 中执行此操作?

最佳答案

就在这里,但请先尝试在 Google 上查找

Sub eachCell()
Dim c As Range
For Each c In Range("A1:D21")
If (c.Value = "mytext") Then 'if value of cell = "specific text"
c.Value = "other text" 'do this
Else
c.Value = "other text 2" 'do that
End If
Next c
End Sub

关于excel - 检查范围内的每个单元格是否有特定字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41478934/

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