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
 
Happy to have been of help.
Do my one favour though, give you tables a meaningful name. They appear in formulas, in Pivot Table Sources and Power Query Sources and having table names of Table1, 2, 3 etc is not particularly helpful.
Also I like to have a prefix for the name eg tbl or db, so that when you forget the table name (and you will) you can just type in =tbl in a formula and you get just the table. And in the Name Manager they group together.
 
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Oops - pilot error. I am at work now (where I don't and shouldn't have the XL2BB copying plug-in installed for a screen shot).

Turns out I was imagining things, or inserting a 'semantic' rather than eidetic memory, thinking that the word "Invoice" was even in those reports, and that the invoice #'s were longer than they appear on the actual receipts, so your nice solutions aren't quite applicable.

They just have the Invoice #, customer name & account # and time of transaction. Both the department and individual product level invoice reports are of this form:

1-318333 John Public #89301) on 9/1/2021 8:42:15AM for 0.00 hrs 0.00 min 39.00 sec
(then rows for either all the department name or SKUs for that invoice, # of items, and retail value, as before ...albeit with a completely blank & useless column C between)
Total: 1-318333 John Public #89301) on 9/1/2021 8:42:15AM for 0.00 hrs 0.00 min 39.00 sec

(unless the customer doesn't have an account, in which case it's just:

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 sec
Total: [as above]

Rather than learn how to do those extractions with a new formulae I tried to gerrymandering the results by Searching & replacing Total: for Total: Invoice and the inserting Invoice: before the 'Begins with 1-" rows to use your same formula, but it didn't go well with my initial type of pivot table which wouldn't filter the resulting first column the same way, so I'll have to get back to this tonight at home since I'm way behind in my normal work.
 
Upvote 0
by the way, in case this makes a difference for that invoice extraction formula in column D, I was just using "Dept 1" etc as placeholders for the names, which are words or phrases of indeterminate length (one of which is indeed "Shipping"). Similarly, although most of the store codes are either 4 or 4 digits long, some (like the Shipping codes and MI for misc) are just letters, and there's even the odd barcode in there by mistake.
 
Upvote 0
Hi. Thanks for coming back. Yes, in about an hour, from home. (I'm still at work and am reluctant to use the plug in here.)

I just ran a month's worth with a better search&replace insertion of "Invoice" and expanding the number of characters to make it work....

but encountered a glitch: starting at invoice # 1-318999 it indexed all the remaining ones under that, with the pivot table giving it a huge total, whereas the invoices continued onto # 1-320250.
 
Upvote 0
Thanks again for bearing with me. Here's the first ten or so transactions for last month as they appear in the export, except I added the header row and swapped out the names for John / Jane Doe type ones. Note, besides the blank column in the middle, the Qty & Total ones are reversed, which doesn't really enter into the formulae you created, as it happens, just for the pivot table

1 week sales.xls
ABCD
1VariableQty[blank[Total
21-320151 Doe John #91583) on 9/30/2021 8:58:19AM for 0.00 hrs 3.00 min 21.00 sec
3Shipping19.99
4Water Systems / Accessories And Services1349.99
5Total: 1-320151 Doe John #91583) on 9/30/2021 8:58:19AM for 0.00 hrs 3.00 min 21.00 sec2359.98
61-320152 Doe Jane #91584) on 9/30/2021 9:37:41AM for 0.00 hrs 0.00 min 25.00 sec
7Food Preparation Appliances / Gadgets1929.99
8Shipping10.00
9Total: 1-320152 Doe Jane #91584) on 9/30/2021 9:37:41AM for 0.00 hrs 0.00 min 25.00 sec2929.99
101-320153 Doe Johnathan #90354) on 9/30/2021 10:03:14AM for 0.00 hrs 0.00 min 20.00 sec
11Professional Supplements144.99
12Total: 1-320153 Doe Johnathan #90354) on 9/30/2021 10:03:14AM for 0.00 hrs 0.00 min 20.00 sec144.99
131-320154 Doe Joneathan #58069) on 9/30/2021 10:09:05AM for 0.00 hrs 0.00 min 31.00 sec
14Air Purifiers And Humidifiers197.49
15Total: 1-320154 Doe Joneathan #58069) on 9/30/2021 10:09:05AM for 0.00 hrs 0.00 min 31.00 sec197.49
161-320155 No Refunds, Credits, Exchanges Without This Invoice #22874) on 9/30/2021 10:09:40AM for 0.00 hrs 0.00 min 21.00 sec
17Supplements124.99
18Total: 1-320155 No Refunds, Credits, Exchanges Without This Invoice #22874) on 9/30/2021 10:09:40AM for 0.00 hrs 0.00 min 21.00 sec124.99
191-320156 Public John Q #35418) on 9/30/2021 10:17:03AM for 0.00 hrs 0.00 min 23.00 sec
20Food215.98
21Total: 1-320156 Public John Q #35418) on 9/30/2021 10:17:03AM for 0.00 hrs 0.00 min 23.00 sec215.98
221-320157 No Refunds, Credits, Exchanges Without This Invoice #22874) on 9/30/2021 10:22:25AM for 0.00 hrs 8.00 min 23.00 sec
23Price Match352.47
24Professional Supplements281.50
25Supplements245.98
26Total: 1-320157 No Refunds, Credits, Exchanges Without This Invoice #22874) on 9/30/2021 10:22:25AM for 0.00 hrs 8.00 min 23.00 sec7179.95
271-320158 Public Jane #76774) on 9/30/2021 10:46:57AM for 0.00 hrs 0.00 min 39.00 sec
28Price Match241.17
29Total: 1-320158 Public Jane #76774) on 9/30/2021 10:46:57AM for 0.00 hrs 0.00 min 39.00 sec241.17
301-320159 No Refunds, Credits, Exchanges Without This Invoice #22874) on 9/30/2021 10:56:59AM for 0.00 hrs 0.00 min 24.00 sec
31Personal Care230.98
32Total: 1-320159 No Refunds, Credits, Exchanges Without This Invoice #22874) on 9/30/2021 10:56:59AM for 0.00 hrs 0.00 min 24.00 sec230.98
Sheet1
 
Upvote 0
For the reports by Item no., besides there being more columns (some of which can be left out, I think), there's an annoying wrinkle I've seen this POS program introduce in other types of exports - it offsets two key parts of the total rows: their column B results actually belong two Columns over, in D, and its column D results should be one column to the right (E). That's really going to throw a spanner in the works, as the Brits might say. (me, I'm Canadian.)

Also, in case this matters, both types have hidden line returns in the invoice info, which showed up in these XL2BB lifts, but get suppressed in the normal view unless 'Wrap Text' is activated or edits are done within those Column A cells.

1 day sales.xls
ABCDEFG
1VariableItemQty in StockQty SoldRetail[blank]Vendor #
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 sec
320016Prairie Doctor Brand - Stinging Nettle (50mL)5.02.033.98SNET50
425073St. Francis Herb Farm - Sweet Annie (100mL)5.01.027.990176
57686NOW - Brewer's Yeast 650mg (200 Tablets)0.01.014.99NOW82410
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.96
71-320305 Jane Doe #51506) on 10/2/2021 10:20:16AM for 0.00 hrs 0.00 min 50.00 sec
813275Seracon - Organic Growing Kit - Sprouts # 2 (Crunchy Bean Mix)0.01.08.99EG042
915271Incrediwear - RUN Socks (Grey, Medium, low cut)5.01.016.99InsockPNS502
1020430NOW - Broccoli Seeds for Sprouting (113g)4.01.07.99NOW07215
112152288 Herbs - Rhodiola Rosea (200 mg/90 Veg Caps)13.01.028.95RHO001
122965NOW - Citric Acid (113g)4.01.05.49NOW87320
13Total: 1-320305 Jane Doe #51506) on 10/2/2021 10:20:16AM for 0.00 hrs 0.00 min 50.00 sec568.41
141-320306 John Doe #79605) on 10/2/2021 10:23:29AM for 0.00 hrs 0.00 min 19.00 sec
1513289Piggy Paint Nail Polish - Girls Rule!1.01.09.99PP0021
16Total: 1-320306 John Doe #79605) on 10/2/2021 10:23:29AM for 0.00 hrs 0.00 min 19.00 sec19.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 sec
181049Colour Energy - Headache Relief Blend (10ml, Roll-on)2.01.011.9941060
1919349Nutridom - Premium Bee Propolis 500mg (120 vcaps)14.01.024.99N133
2024763Pocket Square Eco-Friendly Bag34.01.02.00
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.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 sec
2323320TruPure - BioActive Collagen Type II plus MSM (180 capsules)49.02.059.9824
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.98
251-320309 Santa Clause #91445) on 10/2/2021 11:03:12AM for 0.00 hrs 0.00 min 44.00 sec
2625475BlueAir - Blue Pure 411+ Air Purifier2.01.0189.99
27Total: 1-320309 Santa Clause #91445) on 10/2/2021 11:03:12AM for 0.00 hrs 0.00 min 44.00 sec1189.99
281-320310 Johnq Public #43859) on 10/2/2021 11:29:31AM for 0.00 hrs 0.00 min 32.00 sec
2920764Bragg - Apple Cider Vinegar (946mL, Glass Bottle)280.03.023.97260300
3023036AOR - Magnesium Synergy Powder (209g)38.01.036.95AOR04409
31Total: 1-320310 Johnq Public #43859) on 10/2/2021 11:29:31AM for 0.00 hrs 0.00 min 32.00 sec460.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 sec
3324932CanPrev - Collagen Joint & Cartilage (Fortigel) (250g)12.02.069.98195523
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.98
Sheet1
 
Upvote 0
Again, the 'No Refunds, Credits, Exchanges Without This Invoice' string is just what appears on the bottom of our receipts and is what the system spits out for the anonymous customers who haven't opted to set up an account with us and get lumped into one not-really-a-customer customer account.
 
Upvote 0
Update: that glitch I encountered when trying to put the word "Invoice" in the relevant cells and tweak things to work for a month's worth of transactions went away here at home when doing it for a day's worth of invoices.... although that doesn't resolve whether its related to the size of the table or if I just messed something up before.
 
Upvote 0

Forum statistics

Threads
1,223,098
Messages
6,170,103
Members
452,302
Latest member
TaMere

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