Conditional formatting of invoice lists of varying lengths for presence of a given string

Winging It

New Member
Joined
Oct 2, 2021
Messages
44
Office Version
  1. 2013
  2. 2007
Platform
  1. Windows
Hello. I should probably wait until Monday night to get a proper export of the kind I replicated here to work with if there is a possible solution, but I'm posting now in case this volunteer forum might be more active in the weekend, and there might be a greater chance of finding out if it can even be done.

I work at a store, and we'd like to compare the values of our in-person/in-store retail sales versus the online or phone order purchases.. where the latter should all have one of several Shipping Dept codes as part of their invoices (even if zeroed out for free shipping).

(And if there's a solution to that given what we have to work with, the same method could also enable us to find the average total order value of everyone who bought a given item, to help us determine whether it'd be a mistake to stop carrying it, or if a 'loss-leader' was working).

We use a POS/inventory program which *can* generate reports which can be exported to Excel to spit out the invoices as sets, starting with their number and listing either the indiv. store codes & their quantities and retail value (or the Departments those codes are subsets of) followed by the total for each invoice, to look something like this simplified version below, alright.

Problem is, they can't be filtered prior to exporting to only show those orders which include a given item (such as a shipping code) among them.

(Sadly, its filters will only tell us how many times that individual item was sold in a given interval and the value of that, not the total value of the orders they were part of. That's been confirmed by the POS support team themselves; oddly, they haven't programmed reports for orders, just for customers, sales agents, and some other things.)

Of course, the answer IS implicit in these sets of invoices it can generate. But to look at a whole year or even just a month's worth, it would take forever to manually eyeball or control-f down the first column for the instances of Shipping Department (or one of several skus for it) and highlighting / colouring the Invoice total that's part of, to isolate all the totals for all the invoices with some type of shipping attached, and do a subtotal of them.

I'm a complete novice when it comes to Conditional Formatting (and don't know how to do VBA), but from the little I've seen so far from the Q&As here and a couple of videos, it only really applies to what's on it's own row, or on its row relative to a fixed range, rather than what's in nearby rows in sets of indeterminate length.

The Q is,

IS there a way to use either it (or an 'If' function) ranging over the A column (which may be thousands of rows long, depending on the interval I'm looking at), to:

Capture / highlight only those 'begins with Total:' cells which:

have a "begins with: Shipping" (or equals "storecodeX" for the other application) in *any* row immediately above it...

but only UP TO the first instance of "begins with: Invoice) it encounters?

(Unfortunately, there are no blank lines inserted between the individual invoices in this export. If that would help, could the solution include instructions for a macro to insert a blank line after each row in the spreadsheet where Column A begins with Total: ?)

Now, the entries for individual invoices may be anywhere from 1 to about 12 rows long for the exports by Department, where Shipping will not always be the last listed one [...although I suppose I could fix that by creating a new XXShipping Parent Category/Department to reassign those codes to, though that may not go over well with the store owner], or,

....up to a couple dozen rows long for the exports done by store code, for the occasional customers who buy tons of stuff at once.

If it helps, the invoice numbers which bookend each set are presumably unique and likely of the same character length; I'll have to wait until Monday night to get back to that, if it's relevant.

Total# Items
Invoice 1xxxxJohnQPublic
Dept 175.003
Dept 28.882
Shipping9.991
Dept 333.333
Total: Invoice 1127.209
Invoice 2xxxxAnonymous
Dept 199.991
Dept 262.374
Dept 377.771
Total: Invoice 2xxxxAnonymous240.136
Invoice 3xxx
Dept 172.131
Dept 28.882
Dept 599.991
Dept 672.133
Shipping9.991
Dept 862.374
Total: Invoice 3xxx325.4912
Invoice 4xxx
Dept 172.133
Total: Invoice 3xxx72.133
 
Is the length and format of the invoice number fixed eg 1-320151 and always starting with 1- ?
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
yes, I believe so, 6 digits for the invoice itself, and where the 1- is because at one point they had 2 physical stores.
 
Upvote 0
Hmmm... now that I'm staring at a bigger table (of 3/4's of a day's sales I'd exported at about 2 hours before the store closes) using your solution, I guess it really doesn't matter that the Total lines for the individual product as opposed to departmental exports aren't lined up right, since they really don't figure into the pivot table results, which replicates them on its own.

It's ironic that the very rows I was trying to figure out how to automatically highlight with conditional formatting aren't even needed or used with your method, which labels them only to put them aside -- which is great, considering how this export messes up their alignment in these other types of reports.
 
Upvote 0
Your data in post #16 and in post #18 have different headings and a different number of columns.
Does that mean you have already manipulated the data for post #16 ?
Can you give me the raw format that includes the post #16 & post # 18 types of data.
 
Upvote 0
they are the raw data, except for the addition of the headings and substitutions of the customers names, for two distinct types of reports this aspect of the point of sale program can generate, as to whether it delivers the components of an invoice:

grouped first as a Parent Department, for post 16 and my earlier stick-man versions (where it buries what's included in that); it can do it by dub-department too, which I haven't bothered with yet;

or grouped by product, for post 18. I've just been building up a table with that version, inserting the word Invoice again, and amending the column reference in your formulae accordingly, and swapping the reference to my original target of "Shipping" for a product code, and it worked.
 
Upvote 0
e.g., for one day of sales, there weren't that many SKUs that showed up in multiple invoices to experiment with, but I pulled one out (with a pivot table on just just the SKUs without invoice rows); and:

made the last column's formula:

=IF(I2="Detail",IF(A2<>"21995","Allocated Cost",A2),"")

and did the full pivot table on that using your layout,

and that can indeed be filtered or even just eyeballed to see the three orders with that item among them; two of which bought two other things of comparable value, and one which only bought three of that one thing.

So all that remains to be seen is the invoice numbers can be filled in just by leveraging that '1-' prefix (I played around with that at work, and failed), and whether that auto-fill invoice extracting formula works when the exports is thousands of rows rather than just a few hundred rows long, as to whether that glitch with a month's worth of data was just a hiccup on something I did wrong when using a couple of ways of wedging the word invoice in, earlier today.

Unfortunately, I didn't email myself a whole month's of data to experiment with at home, earlier; only a day's worth, with the two types of exports.
 
Upvote 0
I'm in central time, in the middle of Canada. It's approaching bedtime.

I think it doesn't matter which: they both have the same format for the important bit I'm currently stuck on:

redoing that first
=IF(LEFT(A2,7)="Invoice",MID(A2,9,8),H1) formula (it becomes column H for my wider, post#18 table)
in the absence of that phantom limb word, "Invoice"

Sorry to have been wasting your time in solving an initially misdescribed problem.
 
Upvote 0
This is for #18 - Product view
Ideally you do want to pull out totals as well so you can run an integrity check of totals to detail in a separate pivot.

I didn't have any data that allowed me to put a formula in Sub Type, so left it blank

20211003 Invoice no on all rows.xlsx
ABCDEFGHIJKL
1VariableItemQty in StockQty SoldRetail[blank]Vendor #Line TypeSub TypeInv NoQty_SoldAmount
21-320304 No Refunds, Credits, Exchanges Without This Invoice #22874) on 10/2/2021 10:06:13AM for 0.00 hrs 0.00 min 28.00 secInv Hdg1-320304  
320016Prairie Doctor Brand - Stinging Nettle (50mL)5233.98SNET50Detail1-320304233.98
425073St. Francis Herb Farm - Sweet Annie (100mL)5127.99176Detail1-320304127.99
57686NOW - Brewer's Yeast 650mg (200 Tablets)0114.99NOW82410Detail1-320304114.99
6Total: 1-320304 No Refunds, Credits, Exchanges Without This Invoice #22874) on 10/2/2021 10:06:13AM for 0.00 hrs 0.00 min 28.00 sec476.96Total1-320304476.96
71-320305 Jane Doe #51506) on 10/2/2021 10:20:16AM for 0.00 hrs 0.00 min 50.00 secInv Hdg1-320305  
813275Seracon - Organic Growing Kit - Sprouts # 2 (Crunchy Bean Mix)018.99EG042Detail1-32030518.99
915271Incrediwear - RUN Socks (Grey, Medium, low cut)5116.99InsockPNS502Detail1-320305116.99
1020430NOW - Broccoli Seeds for Sprouting (113g)417.99NOW07215Detail1-32030517.99
112152288 Herbs - Rhodiola Rosea (200 mg/90 Veg Caps)13128.95RHO001Detail1-320305128.95
122965NOW - Citric Acid (113g)415.49NOW87320Detail1-32030515.49
13Total: 1-320305 Jane Doe #51506) on 10/2/2021 10:20:16AM for 0.00 hrs 0.00 min 50.00 sec568.41Total1-320305568.41
141-320306 John Doe #79605) on 10/2/2021 10:23:29AM for 0.00 hrs 0.00 min 19.00 secInv Hdg1-320306  
1513289Piggy Paint Nail Polish - Girls Rule!119.99PP0021Detail1-32030619.99
16Total: 1-320306 John Doe #79605) on 10/2/2021 10:23:29AM for 0.00 hrs 0.00 min 19.00 sec19.99Total1-32030619.99
171-320307 No Refunds, Credits, Exchanges Without This Invoice #22874) on 10/2/2021 10:24:41AM for 0.00 hrs 0.00 min 26.00 secInv Hdg1-320307  
181049Colour Energy - Headache Relief Blend (10ml, Roll-on)2111.9941060Detail1-320307111.99
1919349Nutridom - Premium Bee Propolis 500mg (120 vcaps)14124.99N133Detail1-320307124.99
2024763Pocket Square Eco-Friendly Bag3412Detail1-32030712
21Total: 1-320307 No Refunds, Credits, Exchanges Without This Invoice #22874) on 10/2/2021 10:24:41AM for 0.00 hrs 0.00 min 26.00 sec338.98Total1-320307338.98
221-320308 No Refunds, Credits, Exchanges Without This Invoice #22874) on 10/2/2021 10:57:09AM for 0.00 hrs 0.00 min 38.00 secInv Hdg1-320308  
2323320TruPure - BioActive Collagen Type II plus MSM (180 capsules)49259.9824Detail1-320308259.98
24Total: 1-320308 No Refunds, Credits, Exchanges Without This Invoice #22874) on 10/2/2021 10:57:09AM for 0.00 hrs 0.00 min 38.00 sec259.98Total1-320308259.98
251-320309 Santa Clause #91445) on 10/2/2021 11:03:12AM for 0.00 hrs 0.00 min 44.00 secInv Hdg1-320309  
2625475BlueAir - Blue Pure 411+ Air Purifier21189.99Detail1-3203091189.99
27Total: 1-320309 Santa Clause #91445) on 10/2/2021 11:03:12AM for 0.00 hrs 0.00 min 44.00 sec1189.99Total1-3203091189.99
281-320310 Johnq Public #43859) on 10/2/2021 11:29:31AM for 0.00 hrs 0.00 min 32.00 secInv Hdg1-320310  
2920764Bragg - Apple Cider Vinegar (946mL, Glass Bottle)280323.97260300Detail1-320310323.97
3023036AOR - Magnesium Synergy Powder (209g)38136.95AOR04409Detail1-320310136.95
31Total: 1-320310 Johnq Public #43859) on 10/2/2021 11:29:31AM for 0.00 hrs 0.00 min 32.00 sec460.92Total1-320310460.92
321-320311 No Refunds, Credits, Exchanges Without This Invoice #22874) on 10/2/2021 11:41:36AM for 0.00 hrs 0.00 min 29.00 secInv Hdg1-320311  
3324932CanPrev - Collagen Joint & Cartilage (Fortigel) (250g)12269.98195523Detail1-320311269.98
34Total: 1-320311 No Refunds, Credits, Exchanges Without This Invoice #22874) on 10/2/2021 11:41:36AM for 0.00 hrs 0.00 min 29.00 sec269.98Total1-320311269.98
Product View
Cell Formulas
RangeFormula
J2:J34J2=IF(H2="Inv Hdg",LEFT(A2,8),J1)
K2:K34K2=IF($H2="Detail",D2,IF($H2="Total",B2,""))
L2:L34L2=IF($H2="Detail",E2,IF($H2="Total",D2,""))
H2:H34H2=IF(LEFT(A2,6)="Total:","Total",IF(AND(E2="",MID(A2,2,1)="-"),"Inv Hdg","Detail"))


1633405326603.png
 
Upvote 0
I'm in central time, in the middle of Canada. It's approaching bedtime.

I think it doesn't matter which: they both have the same format for the important bit I'm currently stuck on:

redoing that first
=IF(LEFT(A2,7)="Invoice",MID(A2,9,8),H1) formula (it becomes column H for my wider, post#18 table)
in the absence of that phantom limb word, "Invoice"

Sorry to have been wasting your time in solving an initially misdescribed problem.
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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