Hi there. So I am fairly new to vba but I have had quite the crash course in it at my work. I've been going through a massive macro that has been used by my company for almost a decade. It is barely holding together so I have been slowly trying to improve it. There is one area I think might be able to be optimized but I am not sure, so I wanted to ask. Basically, this macro uses three IF statements that I think could be combined to cut out the middle step. First, it looks at data in one column and has a bunch of IF statements saying to check one column for certain values and if they match, go to another part of the code. At that designated part of the code it writes a certain number (there are 40 possible numbers). This is looped for all rows. Then, another IF statement checks the newly entered numbers made by that set of code and for each number to perform an action to another column. I am thinking, wouldn't it be simpler to cut out the step where it writes the numbers and instead use the first IF statement to go directly to the last one that modifies the data.
For example, right now it looks something like this:
Keep in mind there are about 40 of these statements all pretty much identical just with different numbers depending on what the WC value is.
If WC = "138-5733" Or WC = "138-5230" Then GoTo 1
1 Cells(Row, 11) = 6
If Cells(Row, 11) = 6 Then GoTo 506
506 If myday = 2 Then cellduedate = ordduedate - 10
So I'm wondering if there would be any harm in changing it to be:
If WC = "138-5733" Or WC = "138-5230" Then GoTo 506
506 If myday = 2 Then cellduedate = ordduedate - 10
Could anyone tell me if there might be any unintended consequences to making this change? Would it even help? The numbers that are added in column 11 using this code are never used again in the macro so leaving them out will not have an effect on the rest of the macro.
Thank you!
Bookmarks