Hi all
I have several macros on the go at the moment for work and I am trying to improve them somewhat.
The macros go into other spreadsheets and extract data from them.
The other spreadsheets all have general name formats based on their purpose/results/date or week of the year.
However, since they are manually saved files from other people, the file names are subject to errors etc. I generally try and account for this with multiple nested if statements to check for the correct file name based on the length function.
Example
What I am wondering is if it possible to incorporate the GOTO command into the IF statement, eg set labels on each file open process, and then if the file name returns a zero length the GOTO command can be used to skip all the code associated with that worksheet and instead of exiting, open the next sheet in the list and start working on that...
My questions are...1) is this possible? & 2) I saw some comments that say the use of the GOTO command in programming is not best practice, so is there another way I should do this instead?
Thanks in advance for any help / information.
Regards
Patrick
I have several macros on the go at the moment for work and I am trying to improve them somewhat.
The macros go into other spreadsheets and extract data from them.
The other spreadsheets all have general name formats based on their purpose/results/date or week of the year.
However, since they are manually saved files from other people, the file names are subject to errors etc. I generally try and account for this with multiple nested if statements to check for the correct file name based on the length function.
Example
Code:
If Len(Dir(ivrPath + FE)) = 0 Then
MsgBox "Finance Export Not Found - please make sure the file name is 'Finance Export DD.MM.YYYY.xls"
Exit Sub
Else
Workbooks.Open ivrPath + FE, , 1
End If
My questions are...1) is this possible? & 2) I saw some comments that say the use of the GOTO command in programming is not best practice, so is there another way I should do this instead?
Thanks in advance for any help / information.
Regards
Patrick