Check spelling - exit on Escape

Formula11

Active Member
Joined
Mar 1, 2005
Messages
468
Office Version
  1. 365
Platform
  1. Windows
I'm checking spelling in Excel using VBA and was looking to have 2 functionalities.
1. Go to cell when checking. This is done with Cell.Select.
2. If Esape or Close is pressed, to Exit. It works with If Not Cell.CheckSpelling Then Exit Sub, but then then you can't go the cell for some reason.

Is there a way to have both work?

VBA Code:
Sub Spelling()
    Dim Cell As Range
    For Each Cell In ActiveSheet.UsedRange
'If Not Cell.CheckSpelling Then Exit Sub
        If Len(Cell) > 0 Then
            Cell.Select
            Cell.CheckSpelling
        End If
    Next Cell
End Sub
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi Formula11

Why check each cell like that, if you check the whole range in one then the CheckSpelling will stay open for all spelling mistakes and close on exit/ESC or finished spell checking

VBA Code:
ActiveSheet.UsedRange.CheckSpelling
 
Upvote 0
Yes, but it will be used in another context later, I won't be checking every cell.
 
Upvote 0
Sorry but not sure there is a way to interupt the loop as I can't find any trigger that sets off when canceling the spell check dialog
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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