A Sub/Function to cause another Sub/Function to Exit
"Zone" wrote:
IT, make newCell a Function so it can return a value to the calling routine.
James
Function newCell() as Boolean
newCell=True
<snip
ElseIf curCell 45 Then
MsgBox "No more line entries available." & _
Chr(13) & "Please combine your entries and resubmit."
NewCell=False
Exit For
Else
ActiveCell.Offset(1, 0).Select
End If
Next
End Function
Thanks Guys for the suggestions.
I noticed Tom put "newCell = True" after the For loop and Zone/James put it
ahead of the For loop. Do I have to declare newcell = True/False outside of
the For loop at all?
Tom: I added in an "Exit For" (in code below) to get it to stop cycling
through the cells to cell L45. There's a locked cell @L46 and it generated an
error about accessing locked cells. Otherwise your code worked perfect.
Thanks!
Zone/James: I still don't quite get the difference between a function and a
sub, but i guess that's part of learning! Maybe you could shed some light?
(code)
If (whiteSpace.test(ActiveCell.value)) Then
newCell = True
Exit For '<======[ THIS ]
|