# Dynamic Subtraction

1. ## Dynamic Subtraction

Say I've got cells A1-A10 populated with numbers. My initial formula in cell B1 is =A1-A6. However, I'd like to strike-out cell A3 (keeping the contents visible underneath the strike-out if possible), and I'd like the formula in B1 to recognise that change, and then automatically adjust itself to =A1-A7 (the idea being that I'd like A1 subtracted by the number in the cell 5 "non-struck out" cells below it). And then if I strike out cell A5 I'd like the formula to adjust itself to =A1-A8 and so on. Does anyone know how to do this? Thanks in advance!

2. ## Re: Dynamic Subtraction

Try something like this.
//Ola

A1:A10 Numbers striked through
B1:B10 =IsStrikeThrough(A1) fill down
C1: =SUMIF(B1:OFFSET(B1,,,6+COUNTIF(B1:B10,TRUE())),FALSE(),A1:OFFSET(A1,,,6+COUNTIF(B1:B10;TRUE())))

``Please Login or Register  to view this content.``
Alt+F11, Insert Module, copy and paste the above code

3. ## Re: Dynamic Subtraction

Hi Ola,

I've had a go at what you've recommended, but I can't seem to get it to work...

Firstly - the =IsStrikeThrough(A1) in the B column isn't being recognised.

Secondly - it won't allow me to input the code you've given into cell C1

Lastly - I'm not sure if I'm inserting the module correctly? I've got a Mac and am using Excel 2008 - so perhaps there is another way to insert the module?

4. ## Re: Dynamic Subtraction

Hi JKK and welcome to the forum

i would suggest you upload a sample work book, (all sensitive data removed), showing what data you are working with, a few examples of what your expected outcome is, and how you arrived at that
To attach a file to your post,
click advanced (next to quick post),
scroll down until you see "manage file",
click that and select "add files" (top right corner).
click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

Once the upload is completed the file name will appear below the input boxes in this window.
You can then close the window to return to the new post screen.

5. ## Re: Dynamic Subtraction

Here the Macro for your file.
//Ola

6. ## Re: Dynamic Subtraction

Thanks FDibbins, glad to be here!

Hopefully what I've uploaded there makes sense. I guess if anyone can reply with that file updated with formulas/macros that solve my problem, that would be great also!

7. ## Re: Dynamic Subtraction

There are no regular formulas that will recognize formatting (because it is purely cosmetic).

The approach I took was to add a column where you can enter a character (I used X), instead of using strikeout.

I used C for the X, and then in D, copied down, i used this...

=B1-OFFSET(B1,5+COUNTIF(C1:C6,"X"),0)

8. ## Re: Dynamic Subtraction

Thanks so much! That works pretty much exactly as I'd like it to! Thanks FDibbins and also Ola for the help!

One quick addition - would it be possible for the cell to place an X if the equivalent cell in the other column has an X in it - ie, once C1 has an X in it, then D1 instead of continuing to use the formula and calculating a new result, it places an X in the cell - and if C5 has an X, then D5 also has an X etc...?

9. ## Re: Dynamic Subtraction

try this...
=IF(C1="X","X",B1-OFFSET(B1,5+COUNTIF(C1:C6,"X"),0))

10. ## Re: Dynamic Subtraction

Wow! Yes, now that works absolutely perfectly! Thanks so so much!

11. ## Re: Dynamic Subtraction

Happy to help. If this answered your question, please take a moment to mark the thread as "solved" - it helps keep things neet and tidy lol, and consider adding the reputation to those that helped (see points 2 & 3 below)

There are currently 1 users browsing this thread. (0 members and 1 guests)