Max Excluding Strikethrough

cjhardin

New Member
Joined
Nov 16, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have a data set where randomly things have strikethroughs in it due to errors in that data collection. The strikethroughs are put in manually. I'm trying to figure out how I could code a max of a set of 10 numbers excluding the numbers that have had a strikethrough applied to the set of numbers. I have over 100 data sets so that is why I'm trying to streamline this with a code. I've included an example below of what one of these sets of data would look like that I would need to pull information from.

1637073462050.png
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi, I think you'd need to use a user defined function for that.

Here is one option for that.

VBA Code:
Function max_no_strikethrough(r As Range) As Double
Dim c As Range
For Each c In r
    If Not c.Font.Strikethrough Then
        If IsNumeric(c.Value) Then
            If c.Value > max_no_strikethrough Then max_no_strikethrough = c.Value
        End If
    End If
Next c
End Function

To use, insert the code above into a standard code module in the VBA editor (ALT+F11 from Excel), save your workbook as an .XLSM file and use in the worksheet as below.

EDIT - the XL2BB mini-sheet doesn't show the strikethrough formatting, it has been applied to the noted rows in column C.

Book3
BCD
12122.5
221.8
322.5
418.9
527.5this has strikethrough
638this has strikethrough
721.8
820.6
926.6this has strikethrough
1017.9
Sheet1
Cell Formulas
RangeFormula
D1D1=max_no_strikethrough(B1:B10)
 
Upvote 0
Solution
Hi, I think you'd need to use a user defined function for that.

Here is one option for that.

VBA Code:
Function max_no_strikethrough(r As Range) As Double
Dim c As Range
For Each c In r
    If Not c.Font.Strikethrough Then
        If IsNumeric(c.Value) Then
            If c.Value > max_no_strikethrough Then max_no_strikethrough = c.Value
        End If
    End If
Next c
End Function

To use, insert the code above into a standard code module in the VBA editor (ALT+F11 from Excel), save your workbook as an .XLSM file and use in the worksheet as below.

Book3
BCD
12122.5
221.8
322.5
418.9
527.5this has strike tthrough
638this has strike tthrough
721.8
820.6
926.6this has strike tthrough
1017.9
Sheet1
Cell Formulas
RangeFormula
D1D1=max_no_strikethrough(B1:B10)


EDIT - the XL2BB mini-sheet doesn't show the strikethrough formatting, it has been applied to the noted rows in column C.
That has seemed to worked well with what I'm doing. I knew it would need a VBA related solution, thank you for your help!
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,252
Members
449,075
Latest member
staticfluids

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