Removing HTML from a Cell in Google Sheets

Last updated on: Published by: Remedy667 0

So, I do a lot of editing website data and HTML in Google Sheets. A lot of the time it’s a lot of old stuff that someone else populated, sometimes it’s been extracted from a vendor website, and it’s almost always in need of some sort of repair.

Recently I came across this beauty:

Excessive HTML in a Google Sheets Cell

Which made me think about a way that I would first need to wipe all of the HTML. Usually I would just do a Find and Replace for <br /> or <p> tags and knock them out one at a time, but as you can see from the image about. This is a particularly special case, and I found this solution over on Stack Overflow that I’d like to share here for my own personal use, and to hopefully help out anyone else who experiences this problem.

In the Stack Overflow post, they mention 2 ways of accomplishing this, but I’m only going go over one of them (and modify it a bit):

=REGEXREPLACE(A1,"</?[^<>]*>","")

So looking at what Google says about this tag (REGEXREPLACE(text, regular_expression, replacement)), it’s pretty easy to see what we’re doing. Here, text refers to the cell we’re searching for HTML in (here we used A1, but the cell in my example image would have been K14625), and replacement is telling it to be empty, but what’s going on in the regular_expression?

  • </? = Finds all lesser than symbols to make them the starting point
  • [^<>] = Negates the character class, causing it to match a single character not listed in the character class (greater than & lesser than).
  • *> = Finds all greater than symbols to make that the stopping point (the asterisk helps it to ignore everything after the greater than)

If you go back into the original post, you’ll see that I removed the \S+ in the middle which i believe tells it to ignore whitespace, but that wasn’t relevant for what I was trying to accomplish, and my expression seemed to work just fine. If you’re experiencing problems, try it with the \S+ which can be found using the link above.

Finding and Fixing “Unwanted Dates” with Fractional Data in Sheets

Last updated on: Published by: Remedy667 0

So, I’ve been tasked with sorting a bunch of data that all has to do with measurements… the only problem is, some of it is fractional, some of it is decimal, and some of it is metric. Which creates a couple of separate issues but right now I’m just going to talk about checking for a specific character in a cell.

Decimal Conversion Chart

So, I’ve got this fancy chart for doing my conversions, and my plan is to use the FILTER function so that I can convert them all to decimal… because Sheets does some weird stuff with fractions. For this example I’m going to add the inch symbol to my fractional using this formula:

=A2&”””

This returns the contents of cell A2, and adds the inch marker to the right, like so.

Perfect. Right? What about the fractions of less that 31 that could be easily read as dates?

Highlighted Cells that give undesired result.

Now we’re just going to take the visually simplest route to figure out which cells need fixed, because they all sort of blend together. I’m going to use this formula:

=IF(SEARCH(“/”,CELL),””,””)

You don’t need the IF function, I just wanted any cells that contained the forward slash to return no result. Anything that doesn’t will error out, like so…

Use #VALUE! error to see cells that don’t fraction

So, now that we have those blocks sorted out we can use a different formula on them, to clear the year from their date formatting, and replace it with the inch mark.

=SUBSTITUTE(CELL,”/2020″,””)&””””

Giving us the desired result… and fixing the #VALUE! error…

The story goes on from here, as I begin sorting my blend of Fractional, Decimal and Metric numbers, but I won’t bore you with that for now.

Removing Letters (or Numbers) from a Cell in Google Sheets

Last updated on: Published by: Remedy667 0

First off, I should say that this post should actually be called, how to omit any letter in Google Sheets. It’s another one I forget all the time, and searching the web leads to all sorts of things like macros and plug ins.

Ain’t nobody got time for that…

So here’s the solution that I use, with a brief explanation, and then a bit of real world usage. I figure it makes sense, because I’m trying to use it right now.

=join(“”,split(CELL , “WHAT TO SKIP” ))

What this does is basically says, SPLIT the cell at whatever character you type in the “WHAT TO SKIP” space. Which would normally put everything into a new cell, however, because it’s wrapped in a JOIN tag… it places it all in one cell. The two quote marks with nothing between make sure that your block of text goes uninterrupted.

So, here’s what I’m trying to do.

I have a bunch of part numbers (on the right), where the letters determine the part type, and the number determines the size… but for what I’m doing right now, I don’t care about the size. I only care about the type.

I’m using my code to remove the numbers from the block. Leaving me with the following information.

=countif(RANGE,CRITERIA)

I can now apply a COUNTIF tag to see how many times a certain type is used, and determine what I need to do from there.

In this case, in case anyone is wondering, I’m going to delete almost all of them until I can make all of them have the number one. Which is going to be pretty hand to hand, so that being said… I’m going to get back to it.

Split & Trim with Google Sheets using ArrayFormula

Last updated on: Published by: Remedy667 0

The issue is white space.

=split(CELL,”DELIMITER”)

Using the standard SPLIT formula, to get an unwanted white space at the beginning of each cell. Now, I don’t know about you, but that drives me absolutely nuts, and I’m always forgetting the fix. Ultimately, running through this sequence… over and over and over…

In the following example, I’m attempting to use a formula to split the Category column (K), into its subcategories.

Using the standard SPLIT formula you can see, I’m getting an extra white space at the beginning of each cell in columns D, E & F.

=split(K8,”||”)

It seems that adding an extra space to the end of the delimiter would fix this, only that splits it at every space. I still try to do this sometimes, even though it always fails.

=split(K8,”|| “)

Using TRIM with the formula only returns the data up to the first SPLIT, though I frequently repeat this mistake.

=trim(split(K8,”||”))

We’re so close here, we’re just missing the ARRAYFORMULA function. (ArrayFormula) “Enables the display of values returned from an array formula into multiple rows and/or columns and the use of non-array functions with arrays.” So, in this case, it basically allows you to apply the TRIM function to each cell populated by your SPLIT.

=ArrayFormula(trim(split(K8,”||”)))

Conditional Formatting in Google Sheets

Last updated on: Published by: Remedy667 0

I always forget this, even though it’s super simple. So, I figured the best place to put it so that i would remember… is here in my blog. I use this a lot when I’m working on all kinds of spreadsheets, and I use spreadsheets constantly when I’m working on fonts, and with Adobe inDesign for data merges.

…but we’ll get to that later…

Here’s a quick formatting trick to highlight an entire row in Google Sheets.

Allow me to explain:

From the Sheets menu, select: Format > Conditional Formatting, and a dialog box will open on right side of your spreadsheet. For this example we’re just going to use “Single Color“, which should be the default.

For “Apply to range“, I’m going to apply it to the entire sheet starting at the first position, A1, and take it to the last row and column… which is H500 for this sheet. So, it will look like this:

A1:H500

Next, we’re going to want change “Format cells if…” by clicking on the drop down, and changing it to “Custom formula is“. This is where our formula comes in. For this sheet it is:

=$G1=0

What I’m doing here is having Sheets check to see if anything in column “G” has a value is equal to “0“. I’m applying it to row “1“, because that is the first row affected under “Apply to range” (A1:H500) directly above. These row numbers need match, or else the effected (affected?) rows will be offset, and it will look like your formula did not work.

Here’s a bit of back story (context) for anyone interested.

I was photographing products for a website, and needed to know what products were not in stock at the warehouse before I went searching for them. I used conditional formatting to hide any item that had a quantity of “0” on my printout.

So, here, instead of highlighting… I’m going to be changing the formatting of my cells that are out off stock to match the background color.

Ridiculously simple, but I always forget how to do this. So, now that I’ve written this I should hopefully remember.