Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 23rd, 2005, 10:36 AM
Authorized User
 
Join Date: Nov 2005
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via Yahoo to tonyrosen
Default "Pause" Checking ...

I have a macro which runs through my ranges and checks to see if "some" of them are empty. If they are, it "pauses" (exits, but reenters upon the next range change).

This is what I came up with, but there has to be a better way to do this.

Code:
Private Sub CheckRange() 
    Dim bTrueFalse As Integer 
    Dim iContinue As Integer 
    Dim iNext As Integer 
    Dim sMsgBox As String 
     ' 1 is TRUE - it is filled out
     ' 0 is FALSE - it is not filled out
     ' assume it's filled out
    bTrueFalse = 1 
    For iContinue = 1 To 13 
         '        If Trim(Range("Range" & iContinue).Text) = "" Then
        If IsEmpty(Range("Range" & iContinue)) Then 
            bTrueFalse = 0 
        Else 
            bTrueFalse = 1 
        End If 
        If bTrueFalse = 0 Then 
            Select Case iContinue 
            Case 1 
                MsgBox ("Please fill in the required field: [SUBJECT]") 
                Range("Range" & iContinue).Select 
                Exit Sub 
            Case 2 
                MsgBox ("Please fill in the required field: [FACILITATOR]") 
                Range("Range" & iContinue).Select 
                Exit Sub 
            Case 3 
                MsgBox ("Please fill in the required field: [DATE]") 
                Range("Range" & iContinue).Select 
                Exit Sub 
            Case 4 
                MsgBox ("Please fill in the required field: [PARTICIPANTS]") 
                Range("Range" & iContinue).Select 
                Exit Sub 
            Case 5 
                Range("Range" & iContinue).Select 
            Case 6 
                MsgBox ("Please fill in the required field: [FUNCTIONAL AREA]") 
                Range("Range" & iContinue).Select 
                Exit Sub 
            Case Else 
                Range("Range" & iContinue + 1).Select 
                Exit Sub 
            End Select 
            Exit Sub 
        Else 
            iNext = iContinue + 1 
            Range("Range" & iNext).Select 
        End If 
    Next iContinue 
End Sub
 
Old November 23rd, 2005, 10:57 AM
Authorized User
 
Join Date: Oct 2004
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to shattered Send a message via Yahoo to shattered
Default

Private Sub CheckRange()
    Dim iContinue As Integer
    Dim iNext As Integer
    For iContinue = 1 To 13
        If IsEmpty(Range("Range" & iContinue)) Then
            Select Case iContinue
                Case 1
                    ShowMsg "[SUBJECT]", iContinue
                Case 2
                    ShowMsg "[FACILITAR]", iContinue
                Case 3
                    ShowMsg "[DATE]", iContinue
                Case 4
                    ShowMsg "[PARTICIPANTS]", iContinue
                Case 5
                    Range("Range" & iContinue).Select
                Case 6
                    ShowMsg "[FUNCTIONAL AREA]", iContinue
                Case Else
                    Range("Range" & iContinue + 1).Select
            End Select
            Exit Sub
        Else
            iNext = iContinue + 1
            Range("Range" & iNext).Select
        End If
    Next iContinue
End Sub

Sub ShowMsg(sMsg As String, iCon As Integer)
    MsgBox ("Please fill in the required field: " & sMsg)
    Range("Range" & iCon).Select
End Sub
 
Old November 23rd, 2005, 11:02 AM
Authorized User
 
Join Date: Nov 2005
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via Yahoo to tonyrosen
Default

PERECT!

Thanks!






Similar Threads
Thread Thread Starter Forum Replies Last Post
How Can I Pause Loop dsmike2008 VB How-To 5 July 18th, 2008 01:01 PM
Pause between macros paul20091968 Access VBA 2 April 6th, 2007 01:40 AM
Pause Code stealthdevil Access VBA 5 February 5th, 2007 12:48 PM
Pause Printing rajanikrishna Pro VB 6 0 November 28th, 2004 09:13 PM
Add a Pause snowy0 VB.NET 2002/2003 Basics 3 February 1st, 2004 12:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.