Spellcheck single cell

  • Thread starter Thread starter clayton
  • Start date Start date
C

clayton

I want to only check the spelling in a single cell. When I add th
following it checks the complete sheet.
Private Sub CommandButton7_Click()
Worksheets("master").Unprotect Password:="password"
Range("b24").Select
Range("b24").CheckSpelling
Worksheets("master").Protect Password:="password"
end sub

What am I doing wrong? :
 
Clayton,

Something like the following...

If Application.CheckSpelling(Range("B24").Text) Then ' returns true if OK
MsgBox Range("B24").Text & " is spelled correctly. "
Else
MsgBox Range("B24").Text & " is not spelled correctly. "
End If

Regards,
Jim Cone
San Francisco, CA
 
Well.. I tried that and it did not seem to work as I wished. I stil
want to envoke the internal spellchecker of excel while restricting th
spellchecking to only cell b24.

I tried altering your code to this

If Application.CheckSpelling(Range("B24").text) Then ' returns true i
OK
MsgBox Range("B24").text & " is spelled correctly. "
Else
CheckSpelling (Range("B24").text)
End If

but it is still checking the whole document...
 
Clayton,

'I believe the Sub routine should look like this...

'-----------------------------------
Private Sub CommandButton7_Click()
If Application.CheckSpelling(Range("B24").Text) Then
MsgBox Range("B24").Text & " is spelled correctly. "
Else
MsgBox Range("B24").Text & " is not spelled correctly. "
End If
End Sub
'-----------------------------------

'Also, the code should be in the code module for the sheet
'that has the command button on it.
'You don't say what you want to happen if the text is or is not
'spelled correctly - so I put a MsgBox in for either result.
'If you want to show a message only if the word is incorrectly
'spelled then the code would look like...

'-----------------------------------
Private Sub CommandButton7_Click()
If Not Application.CheckSpelling(Range("B24").Text) Then
MsgBox Range("B24").Text & " is not spelled correctly. "
End If
End Sub
'-----------------------------------

Regards,
Jim Cone
San Francisco, CA
 
Yes, I would like it to check the spelling of cell b24. Either when
exit that cell or click a button. But, as I stated before, I only wan
it to check that one cell. Not the whole sheet.
I understand the if statement you are showing me but how would
accomplish what I am trying to do
 
Clayton,

I am sorry, but I don't understand your problem.
The code I posted works for me and ignores misspelled words in
cells other than "B24".
(Maybe somebody else reading this can help Clayton?)

Regards,
Jim Cone
San Francisco, CA
 
To try to clearify.
I do not want to ignore spelling errors in cell b24. Rather I want t
only check spelling for cell b24 and only b24. If there are spellin
errors in cell b24 then to bring up spell check and correct the errors
After it checks the spelling for cell b24 it should exit. It should no
check the spelling of any other cells.
I hope that helps you understand my problem
 
Clayton,

Ok, we will try one more time.
The following code, I think, does exactly what you want in XL97.
However, in XL2002 you have to click the no button after the spell check.
Give it a try.

'---------------------------------------
Private Sub CommandButton7_Click()
Dim strCellText As String
strCellText = Range("B24").Text

If Len(strCellText) Then
If Application.CheckSpelling(strCellText) Then
MsgBox strCellText & " is spelled correctly. ", , " Spell Check"
Else
Range("B24").CheckSpelling , False, True
End If
Else
MsgBox "There is no text in Cell B24 ", , " Spell Check"
End If
End Sub
'---------------------------------------

Regards,
Jim Cone
San Francisco, CA
 
Hi Clayton,

Give this a try

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 24 And Target.Column = 2 Then
Target.CheckSpelling SpellLang:=1033
Range("B24").Select
Exit Sub
End If
End Sub

HTH
Regards,
Howard
 
This does envoke the spell checker and it does check the spelling o
cell b24. However, it then continues on to the rest of the page an
checks its spelling. Not sure if something is wrong or what but i
looks like it should only be checking cell b24. After it checks th
rest of the page it then asks if I want to check spelling from the to
of the page. That part is ok. But It is still not staying with cel
b24.... Thanks for all your help. Not sure if I am going to get thi
working or not??
Can you think of anything I might be doing wrong
 
Clayton,

Almost there?

It looks like Howard's method which specifies the Language argument makes it
work
the way you want. I don't know why.
So if you change the one line of code, it will look like this...

'--------------------------------------
Private Sub CommandButton7_Click()
Dim strCellText As String
strCellText = Range("B24").Text

If Len(strCellText) Then
If Application.CheckSpelling(strCellText) Then
MsgBox strCellText & " is spelled correctly. ", , " Spell Check"
Else
Range("B24").CheckSpelling SpellLang:=1033 'New Argument
End If
Else
MsgBox "There is no text in Cell B24 ", , " Spell Check"
End If
End Sub

'--------------------------------------

You should also give Howard's code a try, you may like it better.

Regards,
Jim Cone
San Francisco, CA
 
Back
Top