Can I check a word exists in VBA

markh9999

New Member
Joined
Aug 21, 2007
Messages
49
I want to check if text in cell A1 (for example) is a legal word. Is there a way in VBA to look this word up and report back on its validity?

I want to use VBA as I will have lots of words to check (in say cells A1 to A999) and want it to check them all and maybe put a Yes in column B if valid and No if not.

Thanks for any help.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
I want to check if text in cell A1 (for example) is a legal word. Is there a way in VBA to look this word up and report back on its validity?

I want to use VBA as I will have lots of words to check (in say cells A1 to A999) and want it to check them all and maybe put a Yes in column B if valid and No if not.

Thanks for any help.
Are you aware that Excel has a built-in spell checker?
 
Upvote 0
Try

Code:
Sub test()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LR
    With Range("A" & i)
        .Offset(, 1).Value = Application.CheckSpelling(.Value)
    End With
Next i
End Sub
 
Upvote 0
Hi,

Try the below code. If there is any blank cell in the range A1:A999 then it would still show "Yes" otherwise it should do what you are looking for...

Sub legal_word()
For r = 1 To 999
spellresult = Application.CheckSpelling( _
Word:=Cells(r, 1), IgnoreUppercase:=True)
If spellresult = True Then
Cells(r, 2) = "Yes"
Else
Cells(r, 2) = "No"
End If
Next
End Sub


THanks,
Vignesh
 
Upvote 0
This is really weird.

I just tried the letters of the alphabet (a to z) and it says all are legal words except the letter 'i', which, apart from 'a' I would of thought was the only legal one letter word? Any ideas what Excel is doing? It does the same thing for both coding solutions mentioned above?

Thanks
 
Upvote 0
Hello VoG

Nothing unusual is set (I went to Excel Options and checked under 'Proofing' and nothing seemed unusual).

It's doing this:

the TRUE
cat TRUE
b TRUE
i FALSE
x TRUE
y TRUE
z TRUE
 
Upvote 0
PLEASE - can anyone help with this problem - are there any parameters I need to set for the Checkspelling command?
 
Upvote 0

Forum statistics

Threads
1,222,554
Messages
6,166,761
Members
452,069
Latest member
myanis72

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top