JeffGrant
Well-known Member
- Joined
- Apr 7, 2021
- Messages
- 519
- Office Version
- 365
- Platform
- Windows
Hi All,
I have a long module that tests a lot of conditions in the format of:
and so on.
To further fine tune the model I need to incorporate nested ifs.
I already have many nested ifs and that is not a problem.
However, what I would like to do is introduce a structure like
I could achieve this by doing something like:
That would mean that I would have a lot of Goto's and Labels. Is there a better alternative to using so much line jumping?
I am concerned that this is a really poor way to code this module.
Thanks for your suggestions
I have a long module that tests a lot of conditions in the format of:
VBA Code:
If Then
elseif
elseif
elseif
else:
end if
and so on.
To further fine tune the model I need to incorporate nested ifs.
I already have many nested ifs and that is not a problem.
However, what I would like to do is introduce a structure like
VBA Code:
If Then
elseif
elseif
if then
jump to the next elseif outside of this If block.
elseif
end if
elseif
elseif
end if
I could achieve this by doing something like:
VBA Code:
If Then
elseif
elseif
if then
Goto Label_1
elseif
end if
Label_1:
elseif
if then
GoTo Label_2
elseif
end if
Label_2:
elseif
elseif
elseif
end if
That would mean that I would have a lot of Goto's and Labels. Is there a better alternative to using so much line jumping?
I am concerned that this is a really poor way to code this module.
Thanks for your suggestions