Simplify Code - Select Case

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top