+ Reply to Thread
Results 1 to 2 of 2

Simplify Code - Select Case

Hybrid View

  1. #1
    Edgar Thoemmes
    Guest

    Simplify Code - Select Case

    Hi

    Could someone help me simplify the below code. Basically the module is used
    to import some data and format it ready for output. I have the below checks
    to do before any calculations will run, I am adding more reconciliations to
    this list so would like to keep it as simple and as short as possible. Could
    I use a select case statement for this?

    If Worksheets("ZPOHeader").Range("A1").Value <> "" Then
    Call ZPOHeader
    Else
    MsgBox ("Import the ZPOHeader report and then rerun procedure")
    End
    End If

    If Worksheets("ZPOHeader").Range("A1").Value <> "" Then
    Call ZPODetails
    Else
    MsgBox ("Import the ZPODetails report and then rerun procedure")
    End
    End If

    If Worksheets("ABC_Month").Range("A1").Value = "" Then
    MsgBox ("Import the ABC_Month report and then rerun procedure")
    End
    End If

    If Worksheets("ABC_Accum").Range("A1").Value = "" Then
    MsgBox ("Import the ABC_Accum report and then rerun procedure")
    End
    End If


  2. #2
    Dave Peterson
    Guest

    Re: Simplify Code - Select Case

    I'm not quite sure what you're doing, but...

    If Worksheets("ZPOHeader").Range("A1").Value <> "" Then
    'get them both
    Call ZPOHeader
    Call ZPODetails
    Else
    MsgBox ("Import the ZPOHeader report and then rerun procedure")
    Exit Sub 'changed from End
    End If

    If Worksheets("ABC_Month").Range("A1").Value = "" Then
    MsgBox ("Import the ABC_Month report and then rerun procedure")
    Exit Sub
    End If

    If Worksheets("ABC_Accum").Range("A1").Value = "" Then
    MsgBox ("Import the ABC_Accum report and then rerun procedure")
    Exit sub
    End If

    Edgar Thoemmes wrote:
    >
    > Hi
    >
    > Could someone help me simplify the below code. Basically the module is used
    > to import some data and format it ready for output. I have the below checks
    > to do before any calculations will run, I am adding more reconciliations to
    > this list so would like to keep it as simple and as short as possible. Could
    > I use a select case statement for this?
    >
    > If Worksheets("ZPOHeader").Range("A1").Value <> "" Then
    > Call ZPOHeader
    > Else
    > MsgBox ("Import the ZPOHeader report and then rerun procedure")
    > End
    > End If
    >
    > If Worksheets("ZPOHeader").Range("A1").Value <> "" Then
    > Call ZPODetails
    > Else
    > MsgBox ("Import the ZPODetails report and then rerun procedure")
    > End
    > End If
    >
    > If Worksheets("ABC_Month").Range("A1").Value = "" Then
    > MsgBox ("Import the ABC_Month report and then rerun procedure")
    > End
    > End If
    >
    > If Worksheets("ABC_Accum").Range("A1").Value = "" Then
    > MsgBox ("Import the ABC_Accum report and then rerun procedure")
    > End
    > End If


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1