LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default A Sub/Function to cause another Sub/Function to Exit

I have a Sub that dumps information into a worksheet. When a certain amount a
data is dumped, the routine makes a call to another sub to find a clear cell
and then it continues. My range is only from $L$19 to $L$45 and I would like
it if I could use the "new cell" routine to force the termination of the data
dump routine when the range has been exceeded. Possible?

Here's the "new cell" code:

Sub newCell()
Dim whiteSpace As Object
Dim curCell As Integer

Set whiteSpace = CreateObject("VBScript.RegExp")
whiteSpace.IgnoreCase = True
whiteSpace.Pattern = "^\s*$"

If ActiveSheet.name < "myForm" Then Sheet2.Activate
If Not ActiveCell.Address = "$L$19" Then Range("L19").Select

For curCell = 19 To 45
If (whiteSpace.test(ActiveCell.value)) Then
Exit For
ElseIf curCell 45 Then
MsgBox "No more line entries available." & _
Chr(13) & "Please combine your entries and resubmit."
Exit For
Else
ActiveCell.Offset(1, 0).Select
End If
Next
End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Data Validation/Lookup function does function correcty Kirkey Excel Worksheet Functions 2 May 25th 09 09:22 PM
LINKEDRANGE function - a complement to the PULL function (for getting values from a closed workbook) [email protected] Excel Worksheet Functions 0 September 5th 06 03:44 PM
Excel - User Defined Function Error: This function takes no argume BruceInCalgary Excel Programming 3 August 23rd 06 08:53 PM
Need to open the Function Arguments window from VBA for a user defined function. [email protected] Excel Programming 0 June 20th 06 03:53 PM
User-Defined Function pre-empting Built-in Function? How to undo???? MarWun Excel Programming 1 August 6th 03 09:31 PM


All times are GMT +1. The time now is 06:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"