小编chr*_*lly的帖子

VBA如何使用字符串变量循环instr函数?

我刚刚开始学习VBA,我试图让if和loop函数一起工作.我基本上想要在A列中搜索@,如果有@ then = ok,如果不是="无效".我让它工作一行,但循环它为整个列.请提出建议.PS.请放纵我丑陋的第一个定时器代码.

先谢谢你,克里斯汀

Sub help()

    Dim email As String

    email = InStr(email, "@")

    Do While email = InStr(email, "@")
        Cells(email, 1).Value = email
        If email = 0 Then
            Cells(email, 1).Offset(, 1).Value = "Not valid"
        Else
            Cells(email, 1).Offset(, 1).Value = "ok"
        End If 
    Loop

End Sub
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

excel vba excel-vba

2
推荐指数
1
解决办法
2315
查看次数

标签 统计

excel ×1

excel-vba ×1

vba ×1