PC Review


Reply
Thread Tools Rate Thread

Cell by Cell Loop

 
 
Josh O.
Guest
Posts: n/a
 
      14th Apr 2008
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.convertformula(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
 
Reply With Quote
 
 
 
 
Office_Novice
Guest
Posts: n/a
 
      15th Apr 2008
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.convertformula(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

 
Reply With Quote
 
Josh O.
Guest
Posts: n/a
 
      15th Apr 2008
Great...I am one step closer.

Is it possible to have the spell check stop when it hits the lastrow with
data and move to the next column (up to when it hits the Last Column with
data in it)...or have it only check cells with data.

"Office_Novice" wrote:

> 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.convertformula(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

 
Reply With Quote
 
Office_Novice
Guest
Posts: n/a
 
      15th Apr 2008
I am sure its possible. i just dont know how.

"Josh O." wrote:

> Great...I am one step closer.
>
> Is it possible to have the spell check stop when it hits the lastrow with
> data and move to the next column (up to when it hits the Last Column with
> data in it)...or have it only check cells with data.
>
> "Office_Novice" wrote:
>
> > 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.convertformula(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

 
Reply With Quote
 
Josh O.
Guest
Posts: n/a
 
      15th Apr 2008
Anyone else have a thought...

Thanks Office_Novice.

"Office_Novice" wrote:

> 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.convertformula(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

 
Reply With Quote
 
Josh O.
Guest
Posts: n/a
 
      15th Apr 2008
Got it to work...here is the code I am using...

Sub SpellCheck()
ActiveSheet.Unprotect Password:=""

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

x = 1
z = 1

Application.EnableCancelKey = xlDisabled
Application.SpellingOptions.IgnoreMixedDigits = True
Do Until x = LastRow
Do Until z = LastRow
Set mc = ActiveSheet.Cells(x, z)
Application.Goto Reference:=mc, Scroll:=True
ActiveCell.CheckSpelling SpellLang:=1033, AlwaysSuggest:=True
z = z + 1
Loop
z = 3
x = x + 1
Loop
Range("A2").Select
Application.EnableCancelKey = xlEnabled
Application.ScreenUpdating = True
ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True,
Scenarios:=True _
, AllowFormattingCells:=True, AllowSorting:=True, AllowFiltering:=True
MsgBox Prompt:="SpellCheck has been completed!", Buttons:=vbOKOnly,
Title:="SpellCheck"
End Sub

"Josh O." wrote:

> Anyone else have a thought...
>
> Thanks Office_Novice.
>
> "Office_Novice" wrote:
>
> > 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.convertformula(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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Options Yuvraj Microsoft Excel Misc 0 29th Jun 2009 11:20 AM
Populate a cell if values in cell 1 and cell 2 match cell 3 and 4 tviola@wi.rr.com Microsoft Excel Programming 1 21st Aug 2008 10:13 PM
Populate a cell if values in cell 1 and cell 2 match cell 3 and 4 tviola@wi.rr.com Microsoft Excel Worksheet Functions 0 21st Aug 2008 08:44 PM
NEED VBA TO SELECT A CELL; NOTE THE CELL VALUE;COPYADJ CELL;FIND CELL VALUE IN A RANGE AND SO ON CAPTGNVR Microsoft Excel Programming 2 8th Jul 2007 04:18 PM
How to create/run "cell A equals Cell B put Cell C info in Cell D =?Utf-8?B?YWJtYjE2MQ==?= Microsoft Excel Misc 5 26th Jan 2006 06:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:05 PM.