Jefferson Davis 21.Jan.12 12:07 PM a Web browser 1-2-39.8Windows XP
Morning all,
I've created a Sub that in testing works as designed. Now I need to "Loop" it. But, I don't know what type of "loop" is needed for this type of script? I attempted to use the "Goto" method, but it looped until I could force a program shutdown.
Here's what I have:
Sub Duplicate_Remover
' This sub "removes" the "duplicate numbers" from a pre-selected "single column" range.
'
'begin loop here - "Begin-1"
'Begin_1:
' Check for an "Empty" cell.
If Selection.CellDisplay = "" Then
[].MoveCellPointer $Up,1
Sendkeys "({END}{UP})", True ' This line sends the active cell back to the top of a non-empty column.
[].MoveCellPointer $Right,1
[].MoveCellPointer $Left,1
' IF the cell is "Empty" - then END the sub.
End ' Sub Quits Here
Else
'
' Create two "RangeNames" to work with.
CurrentDocument.CreateRangeName "Remove_1", CurrentDocument.Selection
[].MoveCellPointer $Down,1
CurrentDocument.CreateRangeName "Remove_2", CurrentDocument.Selection
'
' Verify the two cells contents.
If Remove_2 <> Remove_1 Then
' IF "Remove_2" isn't the same as "Remove_1"...
CurrentDocument.DeleteRangeName "Remove_1"
CurrentDocument.DeleteRangeName "Remove_2"
'refer back to "Begin_1" and re-start here.
' Goto Begin_1
Else
' IF "Remove_2" is the same as "Remove_1"...
Selection.DeleteRows $Partial
CurrentDocument.DeleteRangeName "Remove_1"
[].MoveCellPointer $Up,1
'refer back to "Begin_1" and re-start here.
' Goto Begin_1
End If
End If
End Sub
Can this sub be converted into a looping sub? and if so, what type of loop is needed?