haydenwatkin
10-15-2019, 07:19 AM
Hi All,
So I'm new to vba, but have experience with other languages, and a lot of excel time under my belt. What I have below is basically a logic map that is obviously not written in VBA. The basic functionality I need is as follows:
Pull from Data in Table1 (23 columns, I am interested in 8 of them) - Varying max rows
Pull from Data in Table2 (23 columns, I am interested in 8 of them) - Varying max rows
Run the comparisons below (all 1s are from table1 and 2s are from table2)
Create Table 3 (2 columns called Predecessor and Successor)
What we're doing here is seeing whether a "Cube" created by a 6 point location for one work statement, overlaps the "Cube" from another work statement.
I am seriously struggling with how to create the below logic in VBA, any help would be appreciated, and let me know if you need more information.
IF BBL_MIN1 > BBL_MAX1
THEN
REPLACE BBL_MIN1 WITH BBL_MAX1 AND BBL_MAX1 WITH BBL_MIN1 (PROBABLY HAVE TO STORE ONE IN A VARIABLE)
END
IF BBL_MIN2 > BBL_MAX2
THEN
REPLACE BBL_MIN2 WITH BBL_MAX2 AND BBL_MAX2 WITH BBL_MIN2 (PROBABLY HAVE TO STORE ONE IN A VARIABLE)
END
FOR EACH IP1 (FROM TABLE 1), TEST ALL OF IP2 ARRAY (FROM TABLE 2)
IF
((WL_MAX1 <= WL_MAX2 AND WL_MAX1 >= WL_MIN2)
OR
(WL_MIN1 >= WL_MIN2 AND WL_MIN1 <= WL_MAX2)
OR
(WL_MIN1 <= WL_MIN2 AND WL_MAX1 >= WL_MAX2))
AND
((STA_MAX1 <= STA_MAX2 AND STA_MAX1 >= STA_MIN2)
OR
(STA_MIN1 >= STA_MIN2 AND STA_MIN1 <= STA_MAX2)
OR
(STA_MIN1 <= STA_MIN2 AND STA_MAX1 >= STA_MAX2))
AND
((BBL_MAX1 <= BBL_MAX2 AND BBL_MAX1 >= BBL_MIN2)
OR
(BBL_MIN1 >= BBL_MIN2 AND BBL_MIN1 <= BBL_MAX2)
OR
(BBL_MIN1 <= BBL_MIN2 AND BBL_MAX1 >= BBL_MAX2))
THEN
CREATE ROW (IN TABLE 3) WHERE PREDECESSOR COLUMN = IP2 AND SUCCESSOR COLUMN = IP1
So I'm new to vba, but have experience with other languages, and a lot of excel time under my belt. What I have below is basically a logic map that is obviously not written in VBA. The basic functionality I need is as follows:
Pull from Data in Table1 (23 columns, I am interested in 8 of them) - Varying max rows
Pull from Data in Table2 (23 columns, I am interested in 8 of them) - Varying max rows
Run the comparisons below (all 1s are from table1 and 2s are from table2)
Create Table 3 (2 columns called Predecessor and Successor)
What we're doing here is seeing whether a "Cube" created by a 6 point location for one work statement, overlaps the "Cube" from another work statement.
I am seriously struggling with how to create the below logic in VBA, any help would be appreciated, and let me know if you need more information.
IF BBL_MIN1 > BBL_MAX1
THEN
REPLACE BBL_MIN1 WITH BBL_MAX1 AND BBL_MAX1 WITH BBL_MIN1 (PROBABLY HAVE TO STORE ONE IN A VARIABLE)
END
IF BBL_MIN2 > BBL_MAX2
THEN
REPLACE BBL_MIN2 WITH BBL_MAX2 AND BBL_MAX2 WITH BBL_MIN2 (PROBABLY HAVE TO STORE ONE IN A VARIABLE)
END
FOR EACH IP1 (FROM TABLE 1), TEST ALL OF IP2 ARRAY (FROM TABLE 2)
IF
((WL_MAX1 <= WL_MAX2 AND WL_MAX1 >= WL_MIN2)
OR
(WL_MIN1 >= WL_MIN2 AND WL_MIN1 <= WL_MAX2)
OR
(WL_MIN1 <= WL_MIN2 AND WL_MAX1 >= WL_MAX2))
AND
((STA_MAX1 <= STA_MAX2 AND STA_MAX1 >= STA_MIN2)
OR
(STA_MIN1 >= STA_MIN2 AND STA_MIN1 <= STA_MAX2)
OR
(STA_MIN1 <= STA_MIN2 AND STA_MAX1 >= STA_MAX2))
AND
((BBL_MAX1 <= BBL_MAX2 AND BBL_MAX1 >= BBL_MIN2)
OR
(BBL_MIN1 >= BBL_MIN2 AND BBL_MIN1 <= BBL_MAX2)
OR
(BBL_MIN1 <= BBL_MIN2 AND BBL_MAX1 >= BBL_MAX2))
THEN
CREATE ROW (IN TABLE 3) WHERE PREDECESSOR COLUMN = IP2 AND SUCCESSOR COLUMN = IP1