![]() |
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 |
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 |
All times are GMT +1. The time now is 02:25 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com