VBA to hide and unhide rows
danielc0 Posted messages 2191 Registration date Status Member Last intervention -
Hello,
I would like to get help with VBA code that would hide and unhide rows in Excel.
See attached file.
The idea is that for each category (Receipts, Expenses and subcategories of expenses), when the user clicks on the down arrow:
- this unhides the detail rows of the category, but only the rows that are not in column E zero or column G zero.
- hides the down arrow.
And when the user clicks on the up arrow:
- this hides the detail rows of the category
- hides the up arrow
- shows the down arrow
- shows the up arrow
I have some knowledge of VBA (beginner) but I don’t know how to approach this.
2 answers
-
Hello Thibault,
I’ve drafted the recipes; you’ll just need to do the same for the rest
https://www.transfernow.net/dl/20260702Mt7AgUg5/dHq5r4Ps
Cheers
-
Hello,
By slightly modifying the sheet, to simplify the VBA code
https://www.swisstransfer.com/d/127480ef-6685-4330-84c7-2cd9f3887591
Daniel
-
Thank you.
Haa it's not bad either. The code seems simpler.
Is it possible to have a few explanations for each block of code so that I can get the hang of it and try to reproduce it?
Perhaps a false impression on my part, but I feel that if from 0€ we move to an amount in column G or I... the row remains hidden anyway... That VBA doesn’t take into account that there is now an amount and that the row should not be hidden.
No?
Stupid question... How to redisplay an image when it has been made invisible by the VBA code?
I added the columns that contain the arrows. I corrected (I think) the amounts to 0. Please check.
I will add comments in the code to explain it when I have corrected any possible errors.
I don’t know how to make an object visible other than by macro. Select the arrow and run:
Sub test() Selection.Visible = True End Sub
https://www.swisstransfer.com/d/ea292767-8234-498e-9f22-7302fbc86ba1
Daniel
-