how to loop through and process two columns in excel
I’ve two tables on a spreadsheet. The largest (the requirements table) with is formatted in the following way:
Req ID | Parent Req ID | Some text column | Process Level ID
The smaller table (the parents table) with the parent requirements is just two columns:-
Parents Req ID | Process Level ID
I’ve been trying to write a script to go through each parent req ID in parent table and find requirements which have the same parent ID in the requirements table and then output the req record Plus the parent req ID somewhere else on the sheet where the process level ID value of the parent and the process level id of the requirement are NOT the same.
I tried to write a script (it’s been years and I’ve forgotten everything) and surprise surprise, it doesn’t work. I didn’t even know how to output the record elsewhere that I just tried to highlight the req record!
I was trying to compare values by using + 2 etc. to get the values from the next but one column
Any pointers on where I’m going wrong would be greatly appreciated.
Sub ProduceEligNonAligned() 'Looping through each of our output cells. For Each g In Range("G2:G21") For Each a In Range("A2:A193") If g.Column = a.Column + 1 Then If g.Column + 2 <> a.Column + 3 Then a.Interior.ColorIndex = 37 'Exit out of this loop and move to the next output cell. Exit For End If End If 'If the columns don't match Next a Next gEnd Sub