View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Office_Novice Office_Novice is offline
external usenet poster
 
Posts: 245
Default Cell by Cell Loop

This isn't pretty but it will do what you want. It will spell check each cell
column by column

Option Explicit

Sub SpellDown()
Do
ActiveCell.Offset(1, 0).Select
ActiveCell.CheckSpelling SpellLang:=1033, _
AlwaysSuggest:=True
On Error GoTo Right
Loop
Right:
ActiveCell.Offset(0, 1).Select
SpellUp
End Sub

Sub SpellUp()
Do
ActiveCell.Offset(-1, 0).Select
ActiveCell.CheckSpelling SpellLang:=1033, _
AlwaysSuggest:=True
On Error GoTo Right
Loop
Right:
ActiveCell.Offset(0, 1).Select
SpellDown
End Sub
"Josh O." wrote:

I need help getting the syntax right for a loop...

This is what I am trying to accomplish:
Start in A2, run spell check on that cell only.
Go to the next cell in that row with data (if any, up to the last column)
and run
spell check on that cell only.

Go to the next cell in that row with data (if any, up to the last last
column) run
spell check on that cell only...etc.
Then move to Row 3 and do the same...
Then Row 4...then 5...etc. Until we hit the last row.

Can someone help me get the syntax right? I know this is probably a ways
off, but this is where I left off. (As you can see..need a lot of help...it
obviously doesn't work).

Sub SpellCheck3()

Dim LastRow As Long
Dim LastCol As Long
LastRow = ActiveSheet.Cells(Rows.Count, "C").End(xlUp).Row
LastCol = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
Debug.Print LastRow, LastCol
Set LastCell = ActiveSheet.Cells(LastRow, LastCol)

x = 2
z = 1

Do Until x = LastRow
Do Until z = LastCol
Set mc = ActiveSheet.Cells(x, z)
Application.Goto(ActiveSheet.Range(mc.convertformu la(formula:=mc,
FromReferenceStyle:=R1C1 _
, ToReferenceStyle:=A1)
Range(x.Address, z.Address).CheckSpelling SpellLang:=1033,
AlwaysSuggest:=True
z = z + 1
Loop
z = 1
x = x + 1
Loop
End Sub