VBA - Format Rows containing word 'Total'

tlc53

Active Member
Joined
Jul 26, 2018
Messages
399
Hi,
I'm using the function Subtotal on my Defined Name range. I would like to format the totals that come through, so that they stand out from the rest of the data. I would like to do this without necessary referring to exact rows/cells, so that the format will work even if the data changes.
My named range is 'CordisTest1'
My data headings are always on row 52
K52 is for heading 'Account' and is what the Subtotal function is based on.
I would like it if column K in my named range 'CordisTest1' contains the word 'Total', cells A:J to the left of it will be formatted to have a plain line border around only, fill 15% grey and be bold font.
Not sure if this is even possible. If not, please could you let me know. Thank you!
 
The reason that you cannot see which data should be sorted is because you didn't place the code where I suggested ..

Sorry! :rolleyes: I missed reading that bit.

So now I can see it is applying the sort. Only one small error is occurring. There is one category called "Free of Charge" which it is putting at the bottom, where in this case, it needs to go at the top. It has zero values associated with it but has 6x transaction lines.

So (in this example) the order it needs to be in as per K21:K35 is;

36164 (Free of Charge)
36165
36167
36168
36169
36170
36162

And the order it is putting it in is;

36165
36167
36168
36169
36170
36162
36164 (Free of Charge)

Is there perhaps a second sort in action that is causing this?

Thank you.
 
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.
Any chance of another sample file with this in it so I can see what is happening and test any possible solution?
 
Upvote 0
Any chance of another sample file with this in it so I can see what is happening and test any possible solution?

I had a think about it and the solution was quite simple. I just ran the range from K20:K35 instead of K21:K35. That way it included the header.

Works an absolute charm. Couldn't have done it without you. Thank you for your help and your patience :)
 
Upvote 0
Can't quite see how that made a difference but it doesn't matter. If it works, that's great. Thanks for letting us know. :)
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

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