Hi All;
I don't know where to start on this project and was hoping for some guidance. I've included a photo to help explain what I am trying to do.
I have a list of information on a "data" sheet. The headers are also listed on an "error rules" sheet (see picture). I have some engineers that need to be able to check their data based on conditions specified on the "error rules" sheet. Each rule has its own row. The reason for the "error rules" sheet is so that the engineers can add rules as production needs change. Currently they are using very complex macros that are difficult to edit (prior to my time). We are talking about 20+ nested IF statements in the formula bar. Messy to say the least.
What I would like to do is have the engineer be able to add rules to the "error rules" sheet as either an OR statement or an AND statement.
The engineer would select AND or OR, the macro looks at all the cells in the row and evaluates each one against the data row in the "data" sheet. The headers in each sheet must match since I am concerned that someone will add columns to the "error rules" sheet that aren't matched to the "data" sheet table layout exactly. I'd like this to be as robust as reasonably possible.
I am going to have them use 1 line per rule. Most of the statements are going to be AND statements. Only a few will be OR statements. The engineer will not be able to use an AND an OR statement in the same row to elevate confusion.
I will have a LOOP so that each row on the "data" sheet will be checked against all of the rules on the "error rules" sheet.
Thought process:
1) Count rows in "data" sheet to determine how many loops to be performed on rule checking and set
2) Count rows in "error rules" sheet to determine the total number of rules that need to be checked
3) Start with Row 1 of "data"
4) check the "data" row for the AND / OR rules line by line on the "error rules" sheet
5) return all record errors to a cell / note on the "data" sheet
6) LOOP process to all records have been validated
What is the best way to start? Matrix, Array, something else? I KNOW that this is going to be the most complex VBA project I have ever undertaken.
Thanks,
Mike
I don't know where to start on this project and was hoping for some guidance. I've included a photo to help explain what I am trying to do.
I have a list of information on a "data" sheet. The headers are also listed on an "error rules" sheet (see picture). I have some engineers that need to be able to check their data based on conditions specified on the "error rules" sheet. Each rule has its own row. The reason for the "error rules" sheet is so that the engineers can add rules as production needs change. Currently they are using very complex macros that are difficult to edit (prior to my time). We are talking about 20+ nested IF statements in the formula bar. Messy to say the least.
What I would like to do is have the engineer be able to add rules to the "error rules" sheet as either an OR statement or an AND statement.
The engineer would select AND or OR, the macro looks at all the cells in the row and evaluates each one against the data row in the "data" sheet. The headers in each sheet must match since I am concerned that someone will add columns to the "error rules" sheet that aren't matched to the "data" sheet table layout exactly. I'd like this to be as robust as reasonably possible.
I am going to have them use 1 line per rule. Most of the statements are going to be AND statements. Only a few will be OR statements. The engineer will not be able to use an AND an OR statement in the same row to elevate confusion.
I will have a LOOP so that each row on the "data" sheet will be checked against all of the rules on the "error rules" sheet.
Example 1:
DEPT = 100 AND Part_Description = Fred
The macro goes to the first row and checks to see if Dept = 100 and Part_Description = Fred
IF conditions = TRUE then insert Error Message "Test 1 - Both Met" into a specified location
Example 2:
#Model_Number = ABC
Part_Level_Number = 2
The macro goes to the first row and checks to see if #Model_Number = ABC or Part_Level_Number=2
IF conditions = TRUE then insert Error Message "Test 2 - 1 or Both Met"
Example 3:
Error Code 1 and 2 are met. Both Error Message need to be entered into a specified cell. There might be 10+ errors that need to be added to the same cell
Thought process:
1) Count rows in "data" sheet to determine how many loops to be performed on rule checking and set
2) Count rows in "error rules" sheet to determine the total number of rules that need to be checked
3) Start with Row 1 of "data"
4) check the "data" row for the AND / OR rules line by line on the "error rules" sheet
5) return all record errors to a cell / note on the "data" sheet
6) LOOP process to all records have been validated
What is the best way to start? Matrix, Array, something else? I KNOW that this is going to be the most complex VBA project I have ever undertaken.
Thanks,
Mike