Avoid Circular Ref

ShalDRH

New Member
Joined
Jul 28, 2021
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hello! I have a data set that comes as an ugly output from another system (I'm unable to adjust this output.) I need to extract a UID for each row that will group multiple rows together. Sample set below.

Here is the issue- The UID value shows up in the middle of its data set. Circular Refs for all of my attempts at a solution.

All of the UIDs will begin with a "56". Additionally, there are rows that begin with 56 but are not UIDs. I tried to "ignore" those 56 but telling it to find the word "blind" and keep looking down instead of equaling the value.

I've tried to trick the formula into working in a ton of ways, but I can't figure out a way for the cells that are AFTER the BUID to read up, while all the others read down to find it. I can't avoid the circular reference.

My example formula here has stripped out all of my convoluted attempts so its less for you to sort thru (and to save me the embarrassment of my attempts at a bandaid!)

Thanks so much for your help and thoughts to set this up!
Shalon



Row identifier formula.xlsm
ABCDE
1XXX
2 Purchasing Cost Summary Report by Lot Date . . . . 2/02/22
3 Time . . . . 17:47:43
4 11.24.11 Formula
5 As of 02/02/22
6XXXA18- First BUID- begins with 56
7XXXA23- also starts with 56 but isn't a BUID
8Rows 19-25 belong with BUID at A18
9XXX
10Code Description
11Lot CostsDesired OutputBUIDCost Code
1240012.01 Foundation Staking56043004156043004140012.01
1340020.01 Inspection 156043004156043004140020.01
1440020.11 Engineering Fees 156043004156043004140020.11
1545530.01 Flatwork Labor/Turnkey 156043004156043004145530.01
1645550.01 FY Landscape & Irrigation56043004156043004145550.01
1745580.01 Window Treatments56043004156043004145580.01
18560430041 8094 Aldred Way560430041560430041560430041 8094 Aldred Way
19Code Buyer Options560430041560430043Code Buyer Options
2013020015 Kitchen Sink - Standard56043004156043004313020015 Kitchen Sink - Standard
2139001005 Lam:Mohawk Rustic Hollow DRW1256043004156043004339001005 Lam:Mohawk Rustic Hollow DRW12
2245002092 Design Finish Package 156043004156043004345002092
2356001005 A Better Blind 2" Faux Wood Co56043004156043004356001005 A Better Blind 2" Faux Wood Co
2481000051 Solar PPA56043004156043004381000051 Solar PPA
25OPTION TOTAL560430041560430043OPTION TOTAL
26Code Description560430043560430043Code Description
27Lot Costs560430043560430043Lot Costs
2840012.01 Foundation Staking56043004356043004340012.01
2940020.01 Inspection 156043004356043004340020.01
3040020.11 Engineering Fees 156043004356043004340020.11
3145330.01 Appliances Complete56043004356043004345330.01
3245520.01 Fencing56043004356043004345520.01
3345530.01 Flatwork Labor/Turnkey 156043004356043004345530.01
3445550.01 FY Landscape & Irrigation56043004356043004345550.01
3545580.01 Window Treatments56043004356043004345580.01
36560430043 8082 Aldred Way560430043560430043560430043 8082 Aldred Way
37Code Buyer Options560430043567650105Code Buyer Options
3813020015 Kitchen Sink - Standard56043004356765010513020015 Kitchen Sink - Standard
3917000110 Cabinets - Tahoe Color: Painte56043004356765010517000110 Cabinets - Tahoe Color: Painte
4039001005 Lam:Mohawk Rustic Hollow DRW1256043004356765010539001005 Lam:Mohawk Rustic Hollow DRW12
4145002092 Design Finish Package 156043004356765010545002092
4256001005 A Better Blind 2" Faux Wood Co56043004356765010556001005 A Better Blind 2" Faux Wood Co
4381000020 Solar Lease56043004356765010581000020 Solar Lease
44OPTION TOTAL560430043567650105OPTION TOTAL
45Code Description567650105567650105Code Description
46Lot Costs567650105567650105Lot Costs
4740012.01 Foundation Staking56765010556765010540012.01
4840020.01 Inspection 156765010556765010540020.01
4940020.11 Engineering Fees 156765010556765010540020.11
5040021.01 Electric Utilities56765010556765010540021.01
5145530.01 Flatwork Labor/Turnkey 156765010556765010545530.01
5245550.01 FY Landscape & Irrigation56765010556765010545550.01
53567650105 6714 Batten Road567650105567650105567650105 6714 Batten Road
54Code Buyer Options5676501050Code Buyer Options
5513020015 Kitchen Sink - Standard567650105013020015 Kitchen Sink - Standard
5617000120 Cabinets - Ellis Color: White567650105017000120 Cabinets - Ellis Color: White
5735001015 Carpet- Chestnut Terrace DR389567650105035001015 Carpet- Chestnut Terrace DR389
5839001005 Lam:Mohawk Rustic Hollow DRW12567650105039001005 Lam:Mohawk Rustic Hollow DRW12
5945002092 Design Finish Package 1567650105045002092
6081000020 Solar Lease567650105081000020 Solar Lease
61OPTION TOTAL5676501050OPTION TOTAL
3 SA0001
Cell Formulas
RangeFormula
D12:D61D12=IF(E12="","",IF(ISNUMBER(SEARCH("blind",E12)),D13,IF(LEFT(E12,2)="56",LEFT(E12,9),D13)))
E12:E61E12=IF(LEFT('3 SA0001'!$A12,1)="","",IF(LEFT('3 SA0001'!$A12,1)="4",LEFT('3 SA0001'!$A12,8),'3 SA0001'!$A12))
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi ShalDRH,

I'm struggling to follow what you want to do. You didn't include your formula with a circular reference so I can't help diagnose but I do see a "Desired Output" column so please tell me if my guesswork is helpful.

If it is then as I'm Excel 2016 you may find other forum members can provide a better 365 solution.

ShalDRH.xlsx
ABCDE
1XXX
2Purchasing Cost Summary Report by Lot Date 2/02/22
3Time . . . . 17:47:43
4 11.24.11 Formula
5As of 02/02/22
6XXXA18- First BUID- begins with 56
7XXXA23- also starts with 56 but isn't a BUID
8Rows 19-25 belong with BUID at A18
9XXX
10Code Description
11Lot CostsDesired OutputBUIDCost Code
1240012.01 Foundation Staking56043004156043004140012.01
1340020.01 Inspection 156043004156043004140020.01
1440020.11 Engineering Fees 156043004156043004140020.11
1545530.01 Flatwork Labor/Turnkey 156043004156043004145530.01
1645550.01 FY Landscape & Irrigation56043004156043004145550.01
1745580.01 Window Treatments56043004156043004145580.01
18560430041 8094 Aldred Way560430041560430041560430041 8094 Aldred Way
19Code Buyer Options560430041560430041Code Buyer Options
2013020015 Kitchen Sink - Standard56043004156043004113020015 Kitchen Sink - Standard
2139001005 Lam:Mohawk Rustic Hollow DRW1256043004156043004139001005 Lam:Mohawk Rustic Hollow DRW12
2245002092 Design Finish Package 156043004156043004145002092
2356001005 A Better Blind 2" Faux Wood Co56043004156043004156001005 A Better Blind 2" Faux Wood Co
2481000051 Solar PPA56043004156043004181000051 Solar PPA
25OPTION TOTAL560430041560430041OPTION TOTAL
26Code Description560430043560430043Code Description
27Lot Costs560430043560430043Lot Costs
2840012.01 Foundation Staking56043004356043004340012.01
2940020.01 Inspection 156043004356043004340020.01
3040020.11 Engineering Fees 156043004356043004340020.11
3145330.01 Appliances Complete56043004356043004345330.01
3245520.01 Fencing56043004356043004345520.01
3345530.01 Flatwork Labor/Turnkey 156043004356043004345530.01
3445550.01 FY Landscape & Irrigation56043004356043004345550.01
3545580.01 Window Treatments56043004356043004345580.01
36560430043 8082 Aldred Way560430043560430043560430043 8082 Aldred Way
37Code Buyer Options560430043560430043Code Buyer Options
3813020015 Kitchen Sink - Standard56043004356043004313020015 Kitchen Sink - Standard
3917000110 Cabinets - Tahoe Color: Painte56043004356043004317000110 Cabinets - Tahoe Color: Painte
4039001005 Lam:Mohawk Rustic Hollow DRW1256043004356043004339001005 Lam:Mohawk Rustic Hollow DRW12
4145002092 Design Finish Package 156043004356043004345002092
4256001005 A Better Blind 2" Faux Wood Co56043004356043004356001005 A Better Blind 2" Faux Wood Co
4381000020 Solar Lease56043004356043004381000020 Solar Lease
44OPTION TOTAL560430043560430043OPTION TOTAL
45Code Description567650105567650105Code Description
46Lot Costs567650105567650105Lot Costs
4740012.01 Foundation Staking56765010556765010540012.01
4840020.01 Inspection 156765010556765010540020.01
4940020.11 Engineering Fees 156765010556765010540020.11
5040021.01 Electric Utilities56765010556765010540021.01
5145530.01 Flatwork Labor/Turnkey 156765010556765010545530.01
5245550.01 FY Landscape & Irrigation56765010556765010545550.01
53567650105 6714 Batten Road567650105567650105567650105 6714 Batten Road
54Code Buyer Options567650105567650105Code Buyer Options
5513020015 Kitchen Sink - Standard56765010556765010513020015 Kitchen Sink - Standard
5617000120 Cabinets - Ellis Color: White56765010556765010517000120 Cabinets - Ellis Color: White
5735001015 Carpet- Chestnut Terrace DR38956765010556765010535001015 Carpet- Chestnut Terrace DR389
5839001005 Lam:Mohawk Rustic Hollow DRW1256765010556765010539001005 Lam:Mohawk Rustic Hollow DRW12
5945002092 Design Finish Package 156765010556765010545002092
6081000020 Solar Lease56765010556765010581000020 Solar Lease
61OPTION TOTAL567650105567650105OPTION TOTAL
3 SA0001
Cell Formulas
RangeFormula
D12:D61D12=LEFT(INDEX($A$10:$A$9999,AGGREGATE(15,6,ROW($A$10:$A$9999)-ROW($A$9)/((LEFT($A$10:$A$9999,2)="56")*(ISERR(SEARCH("blind",$A$10:$A$9999)))),COUNTIF($A$10:$A12,"Code Description"))),9)
E12:E61E12=IF(LEFT('3 SA0001'!$A12,1)="","",IF(LEFT('3 SA0001'!$A12,1)="4",LEFT('3 SA0001'!$A12,8),'3 SA0001'!$A12))
 
Upvote 0
Hi ShalDRH,

I'm struggling to follow what you want to do. You didn't include your formula with a circular reference so I can't help diagnose but I do see a "Desired Output" column so please tell me if my guesswork is helpful.

If it is then as I'm Excel 2016 you may find other forum members can provide a better 365 solution.

ShalDRH.xlsx
ABCDE
1XXX
2Purchasing Cost Summary Report by Lot Date 2/02/22
3Time . . . . 17:47:43
4 11.24.11 Formula
5As of 02/02/22
6XXXA18- First BUID- begins with 56
7XXXA23- also starts with 56 but isn't a BUID
8Rows 19-25 belong with BUID at A18
9XXX
10Code Description
11Lot CostsDesired OutputBUIDCost Code
1240012.01 Foundation Staking56043004156043004140012.01
1340020.01 Inspection 156043004156043004140020.01
1440020.11 Engineering Fees 156043004156043004140020.11
1545530.01 Flatwork Labor/Turnkey 156043004156043004145530.01
1645550.01 FY Landscape & Irrigation56043004156043004145550.01
1745580.01 Window Treatments56043004156043004145580.01
18560430041 8094 Aldred Way560430041560430041560430041 8094 Aldred Way
19Code Buyer Options560430041560430041Code Buyer Options
2013020015 Kitchen Sink - Standard56043004156043004113020015 Kitchen Sink - Standard
2139001005 Lam:Mohawk Rustic Hollow DRW1256043004156043004139001005 Lam:Mohawk Rustic Hollow DRW12
2245002092 Design Finish Package 156043004156043004145002092
2356001005 A Better Blind 2" Faux Wood Co56043004156043004156001005 A Better Blind 2" Faux Wood Co
2481000051 Solar PPA56043004156043004181000051 Solar PPA
25OPTION TOTAL560430041560430041OPTION TOTAL
26Code Description560430043560430043Code Description
27Lot Costs560430043560430043Lot Costs
2840012.01 Foundation Staking56043004356043004340012.01
2940020.01 Inspection 156043004356043004340020.01
3040020.11 Engineering Fees 156043004356043004340020.11
3145330.01 Appliances Complete56043004356043004345330.01
3245520.01 Fencing56043004356043004345520.01
3345530.01 Flatwork Labor/Turnkey 156043004356043004345530.01
3445550.01 FY Landscape & Irrigation56043004356043004345550.01
3545580.01 Window Treatments56043004356043004345580.01
36560430043 8082 Aldred Way560430043560430043560430043 8082 Aldred Way
37Code Buyer Options560430043560430043Code Buyer Options
3813020015 Kitchen Sink - Standard56043004356043004313020015 Kitchen Sink - Standard
3917000110 Cabinets - Tahoe Color: Painte56043004356043004317000110 Cabinets - Tahoe Color: Painte
4039001005 Lam:Mohawk Rustic Hollow DRW1256043004356043004339001005 Lam:Mohawk Rustic Hollow DRW12
4145002092 Design Finish Package 156043004356043004345002092
4256001005 A Better Blind 2" Faux Wood Co56043004356043004356001005 A Better Blind 2" Faux Wood Co
4381000020 Solar Lease56043004356043004381000020 Solar Lease
44OPTION TOTAL560430043560430043OPTION TOTAL
45Code Description567650105567650105Code Description
46Lot Costs567650105567650105Lot Costs
4740012.01 Foundation Staking56765010556765010540012.01
4840020.01 Inspection 156765010556765010540020.01
4940020.11 Engineering Fees 156765010556765010540020.11
5040021.01 Electric Utilities56765010556765010540021.01
5145530.01 Flatwork Labor/Turnkey 156765010556765010545530.01
5245550.01 FY Landscape & Irrigation56765010556765010545550.01
53567650105 6714 Batten Road567650105567650105567650105 6714 Batten Road
54Code Buyer Options567650105567650105Code Buyer Options
5513020015 Kitchen Sink - Standard56765010556765010513020015 Kitchen Sink - Standard
5617000120 Cabinets - Ellis Color: White56765010556765010517000120 Cabinets - Ellis Color: White
5735001015 Carpet- Chestnut Terrace DR38956765010556765010535001015 Carpet- Chestnut Terrace DR389
5839001005 Lam:Mohawk Rustic Hollow DRW1256765010556765010539001005 Lam:Mohawk Rustic Hollow DRW12
5945002092 Design Finish Package 156765010556765010545002092
6081000020 Solar Lease56765010556765010581000020 Solar Lease
61OPTION TOTAL567650105567650105OPTION TOTAL
3 SA0001
Cell Formulas
RangeFormula
D12:D61D12=LEFT(INDEX($A$10:$A$9999,AGGREGATE(15,6,ROW($A$10:$A$9999)-ROW($A$9)/((LEFT($A$10:$A$9999,2)="56")*(ISERR(SEARCH("blind",$A$10:$A$9999)))),COUNTIF($A$10:$A12,"Code Description"))),9)
E12:E61E12=IF(LEFT('3 SA0001'!$A12,1)="","",IF(LEFT('3 SA0001'!$A12,1)="4",LEFT('3 SA0001'!$A12,8),'3 SA0001'!$A12))
Hello Toadstool, Thanks for the reply and for trying to decipher what I needed. I appreciate that!

Your solution works for my data sample, but not when I apply it to the larger data set. I believe because your formula, which looks for "code description", had no way to know that my larger data set has that phrase on another row within the grouping.

So here is me attempting to give you better info :) I hope it makes sense. And isn't too long-winded...

I can't get enough data to copy here to give you a full set, but this list at the end is pretty accurate for the output pattern. (If there is a way to attach an xls doc, I couldn't find it. Is there?) The pattern of this grouping would repeat in general (give or take a few extra/less 4xxxx.xx codes mixed into each grouping if used.) My color-coding and general explanation below-

Row identifier formula v2.xlsm
C
5Pattern of data
6A91- First BUID- (begins with 56) Rows 12-104 are part of this BUID group.
7A102- also starts with 56 but isn't a BUID, so was messing up my formula and I tried to carve it out with finding the word "blind" and ignoring the cell.
8Rows 92-104 are the "afters" that come after the BUID but belong to the group.
3 SA0001


This column below (of the dump) has their codes and descriptions smooshed together and the "Job #" for each cost code is buried rows down and in the middle of the group that it belongs to. I'm trying to get the right job # identified for each row, and isolate the code in another column so they can just filter to their jobs and code to review the rest of the columns to the right (not included).

Due to the limit of data I can copy, I couldn't get my formula in. But the text I've been using is-
  • =IF(A12="","",IF(OR(ISNUMBER(SEARCH("blind",A12)),ISNUMBER(SEARCH("option",A12))),B11,IF(LEFT(A12,4)="8100",B11,IF(LEFT(A12,2)="56",LEFT(A12,9),B13))))
  • The circular reference happens at the sequence that is shown in the example data at rows 101/102. Those two fields in each grouping are circling!

Side note- my formula will populate the first UID (560430041) in ALL of the "after the UID" cells when I double click to auto-populate. Like every set of the "after" cells are that value. Like row 4000 something will still say 560430041 for those "blue" pattern cells. Or they will be blank. I haven't figured out why it does one over the other. And if activate those cells at all they turn into zeros instead of the right/wrong answer. I have no idea why that is happening. Obviously, I'm working above my skill level!

Thanks again for your help.

Row identifier formula v2.xlsm
A
10Code Description
11Lot Costs
1240012.01 Foundation Staking
1340020.01 Inspection 1
1440020.11 Engineering Fees 1
1540021.01 Electric Utilities
1640021.02 Dry House Utility Connection
1740021.03 Sewer and Water Utilities
1840023.01 Finish Grade
1940023.02 Final Grade
2040023.04 Dirt Off Haul
2140025.01 Slab Form & Trench
2240025.03 Slab Pour
2340030.01 Termite Treatment
2442010.01 1st Floor Wall
2542010.03 Roof Sheathing - Carpentry
2642010.04 Framing Labor Complete
2742011.01 1st Floor Lumber
2842015.03 Roof Trusses
2942030.01 Clean Site - First Draw
3042030.02 Clean Site - Second Draw
3142030.03 Clean Site - Final Draw
3242051.02 Ext Door Materials
3342110.01 Window Installation-Labo
3442110.89 Window Labor/Trnky Extras
3542111.01 Windows Materials
3642111.89 Window Material Extras
3742170.01 Plumbing Slab Rough
3842170.02 Plumbing Top Out
3942170.03 Plumbing Final
4042170.89 Plumbing Extras
4142190.01 HVAC Rough
4242190.02 HVAC Final
4342190.03 HVAC-Compressor
4442220.01 Electrical Rough
4542220.02 Electrical Final
4642240.32 Home Automation 2
4742260.01 Fire Sprinkler Sys Rough
4842260.02 Fire Sprinkler Sys Final
4943040.11 Masonry Veneer Complete
5043070.01 Stucco Lath
5143070.02 Stucco Brown
5243070.03 Stucco Complete
5344010.01 Roof Loaded
5444010.02 Roof Laid
5544010.03 Roof Complete
5644050.01 Gutters & Downspouts
5744070.03 Insulation - Wall
5844070.04 Insulation - Attic
5944080.01 Hang Drywall
6044080.02 Drywall Texture
6144081.01 Stock - Drywall
6245000.01 Cabinets Labor
6345001.01 Cabinet Materials
6445020.04 Kitchen Tops-Granite
6545025.02 Vanity Tops-Cultured Marble
6645030.01 Install Exterior Doors
6745030.02 Install Int. Doors & Trim
6845030.03 Install Hardware
6945031.01 Interior Doors
70Code Description
7145100.20 Cultured Marble Walls
7245110.01 Paint Exterior
7345110.02 Paint Interior
7445110.03 Paint Touch Up
7545150.01 Garage Door
7645160.01 Garage Door Opener
7745200.01 Finish Hardware Material-1
7845240.01 Mirrors Bath
7945250.01 Shower Enclosure
8045270.01 Rough Interior Clean
8145270.02 Final Interior Clean
8245270.03 Powder Clean
8345300.01 Hardwood Flooring
8445310.01 Carpet
8545320.01 Light Fixtures
8645330.01 Appliances Complete
8745520.01 Fencing
8845530.01 Flatwork Labor/Turnkey 1
8945550.01 FY Landscape & Irrigation
9045580.01 Window Treatments
91560430041 8094 Aldred Way
92Code Buyer Options
9313020015 Kitchen Sink - Standard
9417000110 Cabinets - Tahoe Color: Painte
9518000025 Bath Vanity - Piedrafina Color
9618000045 Kitchen - Silestone Quartz Col
9725700015 Included Gas Range Pkg: SS F
9835001005 Carpet Pad - Mohawk 3/8" 5lb P
9935001015 Carpet- Chestnut Terrace DR389
10039001005 Lam:Mohawk Rustic Hollow DRW12
10145002092 Design Finish Package 1
10256001005 A Better Blind 2" Faux Wood Co
10381000051 Solar PPA
104OPTION TOTAL
3 SA0001
 
Upvote 0
I'm still not following what the rules are for sectioning each Job#.

You can upload to Google Drive (make sure to set it as share) or use Dropbox to share your spreadsheet but I'd do so as xlsx rather than xlsm.

I still think a different approach using a range for each Job would be best, then use INDIRECT or OFFSET to process each Job. The numbers don't reflect your data but this formula should help identify where each range sits.

ShalDRH.xlsx
B
11st row
282
3101
4121
5 
Sheet1
Cell Formulas
RangeFormula
B2:B5B2=IFERROR(AGGREGATE(15,6,ROW($A$1:$A$9999)-ROW($A$9)/((LEFT($A$1:$A$9999,2)="56")*(ISERR(SEARCH("blind",$A$1:$A$9999)))),ROW()-ROW($B$1)),"")
 
Upvote 0
Thanks for your help. I'll try to make that formula work.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,824
Members
449,050
Latest member
Bradel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top