Hi all,
I am a junior Mechanical Engineer with almost no programming experience. I did some MATLAB a few years ago. I have been given the task of writing a VBA Program in Microsoft Excel to calculate corrosion defects in subsea pipelines. The mathematical calculations themselvs are quite simple however we often have to analyse tens of thousands of data points and this is where excel comes in.
I believe that I am having trouble grasping the "if" function. I understand the concept myself but it is proving difficult to get excel to do what i want it to do. There is a mathematical formula in the ASME standards that I am using known as the "Z Criteria". And if the "Z value" is greater than 50then a certain equation is used and if the Z criteria is less than 50 another equation is used in the calculation. I have copy/pasted the relevant section of the code below.
The intention was that if the calculated "Z-Value" is less than 50 then we use equation 1 and if it is less than 50 then we use equation 2. However when I try to execute this code then I get an error called "Next without for"? I checked all of the "For" definitions and I found that they were all defined. Then I proceeded to check all of the (i,j) definitions for the array sizes and they seem to be ok (as far as I can tell)Please Login or Register to view this content.
Does anyone have any ideas on how to solve this problem. Any help is much appreciated.
I tried to look at the error in the debugging window and the equation that was highligted was due to an incorrect evaluation of the Z criteria and so I think my "if function" could be the culprit.
Thank you very much for your help,
Affan
Bookmarks