Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
列拼写检查VBA Excel_Vba_Excel - Fatal编程技术网

列拼写检查VBA Excel

列拼写检查VBA Excel,vba,excel,Vba,Excel,嗨,我需要检查列中的所有数据的拼写和缩写 这是我的密码: Sub ColorMispelledCells() For Each cl In ActiveSheet.UsedRange If Not Application.CheckSpelling(Word:=cl.Text) Then _ cl.Interior.ColorIndex = 28 Next cl End Sub 无论如何,我可以修改它,使其成为基于列的检查,而不是单元格,也不

嗨,我需要检查列中的所有数据的拼写和缩写

这是我的密码:

Sub ColorMispelledCells()
    For Each cl In ActiveSheet.UsedRange
        If Not Application.CheckSpelling(Word:=cl.Text) Then _
          cl.Interior.ColorIndex = 28
    Next cl
End Sub

无论如何,我可以修改它,使其成为基于列的检查,而不是单元格,也不是高亮显示单元格,而是在下一列中添加注释,说明单词拼写错误或缩写?

您可以将循环更改为for循环,以通过单个列。如果是拼写、缩写等,您需要对消息应该是什么做更多的详细说明

Dim i as Long, j as Long, LR as Long
j = 1 'Setting this up for Column A, aka Column 1
LR = Cells( Rows.Count, j).End(xlUp).Row 'Assumes contiguous column j
For i = 1 to LR
    If Application.CheckSpelling(word:=Cells(i,j).Value)=False Then
        Cells(i,j+1).Value = "SpellCheck Error!"
    End If
Next i

首先,改变你在任何范围内都适用的常规

Sub ColorMispelledCells(r As Range)
    Dim c As Range
    For Each c In r
        if VarType(c.value2) = vbString then
            If Not Application.CheckSpelling(c.Value2) Then
                c.Interior.ColorIndex = 28
            Else
                c.Interior.ColorIndex = 0
            End If
        End If
    Next
End Sub
变量,不着色,但在右边的单元格中写入文本-但请注意,这将覆盖该单元格中的任何内容

c.Offset(0, 1) = "You have misspelled something..."
然后,为按钮添加一个子按钮-这将检查所有正在使用的单元格的拼写(但请注意,这可能需要相当长的时间)

sub ButtonPressed()
    ColorMispelledCells(activesheet.usedRange)
end sub

你的触发器是什么?直接在输入某物之后,或当按下按钮(或类似按钮)时,当按下按钮时,这就是触发器“向下一列添加注释”是什么意思?在
cl.Offset(列:=1)中写入内容
?不清楚您在寻找什么,顺便说一句,
If…Then
语句具有危险的误导性-在
If…End If
块中编写多行
If
语句,并在单行上使用内联条件。这里的行延续和块缩进要求稍后引入错误。您正在迭代eve
ActiveSheet.UsedRange
中的Y单元格。您是否尝试过查看VBA编辑器在
ActiveSheet之后为选项提供的内容。
(在键入该点时)?您的问题看起来像是希望我们做您的研究。这就是我需要的。谢谢!