steveo0707
Board Regular
- Joined
- Mar 4, 2013
- Messages
- 85
- Office Version
- 365
- 2019
- Platform
- Windows
I have an Excel spreadsheet which contains data displaying the thickness(US) and the Magnetic Flux(MF) of steel piping. There are 16 separate channels of piping and each channel is 100,000 centimeters long. This info is recorded every 1 cm. I need help with a VBA code to scan all the data for concern thresholds for each. The concern threshold for (US) is 9.0 and for the (MF) it is 25.0.
The code has to check for 5 different levels.
First Level is to check to see if (US) and (MF) are in range. (US) >= to 9.0 and (MF) <= 25.0
Second Level tells the user that the (US) and (MF) are in the concern range. (US) < 9.0 and (MF) > 25.0
Third Level tells the user that there are multiple level 2 events in adjacent locations
Fourth Level tells the user that both the (US) and (MF) are in the concern range for the same channel number and location
Fifth Level is to tell the user there are multiple level four events in adjacent locations
There are 200 welds in each channel and the (MF) is > 97.99 and (US) is >12.50. The code has to not count these as False Positives for the (MF) parameters, but still needs to detect corrosion at the welds.
I have the code written up to testing for the level three conditions. Not sure how to word the IF statements for Levels 3 thru 5. And not sure how to get the VBA code to scan the info on sheet one of the workbook and display the results on sheet 2 of the same workbook.
The code I have so far is below:
Sub EvaluatePigData()
'Scan Data Worksheet for 5 levels of criteria
Dim MF Channels(16) Dim US Channels(16)
Dim MF As Integer
Dim US As Integer
'Test for level 1 conditions
If MF <= 25.0 and US >= 9.0 Then
Weld Test:
'Test for level 2 conditions
Level 2:
' Test for level 3
Level 3:
The code has to check for 5 different levels.
First Level is to check to see if (US) and (MF) are in range. (US) >= to 9.0 and (MF) <= 25.0
Second Level tells the user that the (US) and (MF) are in the concern range. (US) < 9.0 and (MF) > 25.0
Third Level tells the user that there are multiple level 2 events in adjacent locations
Fourth Level tells the user that both the (US) and (MF) are in the concern range for the same channel number and location
Fifth Level is to tell the user there are multiple level four events in adjacent locations
There are 200 welds in each channel and the (MF) is > 97.99 and (US) is >12.50. The code has to not count these as False Positives for the (MF) parameters, but still needs to detect corrosion at the welds.
I have the code written up to testing for the level three conditions. Not sure how to word the IF statements for Levels 3 thru 5. And not sure how to get the VBA code to scan the info on sheet one of the workbook and display the results on sheet 2 of the same workbook.
The code I have so far is below:
Sub EvaluatePigData()
'Scan Data Worksheet for 5 levels of criteria
Dim MF Channels(16) Dim US Channels(16)
Dim MF As Integer
Dim US As Integer
'Test for level 1 conditions
If MF <= 25.0 and US >= 9.0 Then
Answer = True
ElseMF > 25.0 and US > 12.50 Then
Goto Weld Test
Weld Test:
If MF > 97.99 and US > 12.50 Then
Answer = True
Else
MF <= 97.99 and US <= 12.50 Then
GoTo Level 2
'Test for level 2 conditions
Level 2:
If MF > 25.0 and MF <= 97.99 and US < 9.0 Then
Answer = True
Else
Goto Level 3
Goto Level 3
' Test for level 3
Level 3: