Excel Programing
- Just This Guy
- Posts: 1549
- Joined: Fri Oct 21, 2016 3:30 pm
- Location: Almost Heaven
Excel Programing
Anyone here have experience writing macros in Excel? I am working on a project for work and can't seam to get it to work the way I want it to. I was wondering if anyone here can help mu trouble shoot what I am doing wrong.
"The story so far: In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." -- Douglas Adams
Re: Excel Programing
Maybe. What are you trying to do?
- Just This Guy
- Posts: 1549
- Joined: Fri Oct 21, 2016 3:30 pm
- Location: Almost Heaven
Re: Excel Programing
I'm trying to create a universal reporting form. So based on what they select in a specific cell, the sheet would automatically hide or unhide certain rows.
"The story so far: In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." -- Douglas Adams
Re: Excel Programing
The macro programming does include commands for hiding rows and columns such as:
Rows(2).Hidden = True
That's a full macro programming command and not necessarily an update based in a cell formula. I do not know of a cell formula that would change the "hide" property of a row or column. It seems like something that should exist.
Rows(2).Hidden = True
That's a full macro programming command and not necessarily an update based in a cell formula. I do not know of a cell formula that would change the "hide" property of a row or column. It seems like something that should exist.
Re: Excel Programing
What Corsair said, except that a formula that alters cell attributes should not exist.
(I can make bold statements like this because I'm part of a team at Microsoft Research that consults with Excel's designers on the design of the formula language. I'll follow that posturing up with an explanation, though.)
One of the most important properties of workbook recalc - the cell value updates that happen after you alter a formula - is that it doesn't matter what order the formulas are recalculated in. If order mattered, you would get different answers depending on which cells you edit, because recalc only recalculates the edited cells and the cells that depend on them. Finance companies across the globe would rebel and switch to Google Sheets. Auditors would cry themselves to sleep.
Because there are worksheet functions that are sensitive to which rows are hidden, such as the frequently used SUBTOTAL which can skip hidden rows, allowing a formula to change the hidden attribute would make recalc order matter. If one formula hid a row and another formula showed it, any SUBTOTAL that included that row would give different answers depending on whether each of those formulas was recalculated and in which order. The last recalculated would always have its way.
To avoid all such ambiguities now and in the future, Excel locks down every open workbook during recalc. Not even VBA functions can change them during recalc.
--
Just This Guy: I think you can make Excel do what you want anyway. Corsair's command should work as long as it's run after recalc.
This looks like the kind of thing you want:
https://docs.microsoft.com/en-us/office ... lls-change
I don't know a lot about VBA, but I think by the time Worksheet_Change is called, the cells you want to monitor will have their new values in them, and the workbook will be unlocked so you can hide or show rows.
(I can make bold statements like this because I'm part of a team at Microsoft Research that consults with Excel's designers on the design of the formula language. I'll follow that posturing up with an explanation, though.)
One of the most important properties of workbook recalc - the cell value updates that happen after you alter a formula - is that it doesn't matter what order the formulas are recalculated in. If order mattered, you would get different answers depending on which cells you edit, because recalc only recalculates the edited cells and the cells that depend on them. Finance companies across the globe would rebel and switch to Google Sheets. Auditors would cry themselves to sleep.
Because there are worksheet functions that are sensitive to which rows are hidden, such as the frequently used SUBTOTAL which can skip hidden rows, allowing a formula to change the hidden attribute would make recalc order matter. If one formula hid a row and another formula showed it, any SUBTOTAL that included that row would give different answers depending on whether each of those formulas was recalculated and in which order. The last recalculated would always have its way.
To avoid all such ambiguities now and in the future, Excel locks down every open workbook during recalc. Not even VBA functions can change them during recalc.
--
Just This Guy: I think you can make Excel do what you want anyway. Corsair's command should work as long as it's run after recalc.
This looks like the kind of thing you want:
https://docs.microsoft.com/en-us/office ... lls-change
I don't know a lot about VBA, but I think by the time Worksheet_Change is called, the cells you want to monitor will have their new values in them, and the workbook will be unlocked so you can hide or show rows.
Learn to doubt the stories you tell about yourselves and your adversaries.
Re: Excel Programing
Wow Reuben, I think I had an excelgasm!
Keep talking dirty man, that’s sexy stuff!
Keep talking dirty man, that’s sexy stuff!
“It always devolves to Pantaloons. Always.” ~ Fluffy
“I switched baristas” ~ Lady Gaga
“Those who do not move do not notice their chains.” ~Rosa Luxemburg
“I switched baristas” ~ Lady Gaga
“Those who do not move do not notice their chains.” ~Rosa Luxemburg
Re: Excel Programing
Drag-fill. Relative references. Manual recalc. NPV. Data validation. Name manager! Conditional formatting!
Did you know that if A1 is blank, then A1=False and A1=0 and A1=""? That's my dirtiest secret.
Learn to doubt the stories you tell about yourselves and your adversaries.
Re: Excel Programing
What aboot pivot tables?
Faith does not give you the answers, it just stops you asking the questions. -Frater Ravus
IDKSAF -RubinHighlander
Gave up who I am for who you wanted me to be...
IDKSAF -RubinHighlander
Gave up who I am for who you wanted me to be...
Re: Excel Programing
Ssshhh! Do you want to get him PREGNANT?wtfluff wrote: ↑Fri Mar 06, 2020 2:07 pmWhat aboot pivot tables?
Learn to doubt the stories you tell about yourselves and your adversaries.
Re: Excel Programing
Boy Howdy!
(How soon before a mod marks this thread NSFW? )
Faith does not give you the answers, it just stops you asking the questions. -Frater Ravus
IDKSAF -RubinHighlander
Gave up who I am for who you wanted me to be...
IDKSAF -RubinHighlander
Gave up who I am for who you wanted me to be...
Re: Excel Programing
Aboot? Now your adding a Canadian accent with excel dirty talk? How do you type drooling sounds?
Confession: my girlfriend was Canadian in high school and so I have this thing for Canadian accents. One of the ladies in our corporate office is Canadian so I’ll sometimes call and ask random questions just to chat her up just to hear a thick heavy accent.
“It always devolves to Pantaloons. Always.” ~ Fluffy
“I switched baristas” ~ Lady Gaga
“Those who do not move do not notice their chains.” ~Rosa Luxemburg
“I switched baristas” ~ Lady Gaga
“Those who do not move do not notice their chains.” ~Rosa Luxemburg
Re: Excel Programing
bwleuuuhhfup. mlehhhchchghugfffffffffp. *wipes cheek*
Learn to doubt the stories you tell about yourselves and your adversaries.
Re: Excel Programing
Doh.Red Ryder wrote: ↑Fri Mar 06, 2020 4:23 pmAboot? Now your adding a Canadian accent with excel dirty talk? How do you type drooling sounds?
Confession: my girlfriend was Canadian in high school and so I have this thing for Canadian accents. One of the ladies in our corporate office is Canadian so I’ll sometimes call and ask random questions just to chat her up just to hear a thick heavy accent.
Sorry aboot that. Dang it... Did it again!
I only pretend to be from the Great White North now and again...
Faith does not give you the answers, it just stops you asking the questions. -Frater Ravus
IDKSAF -RubinHighlander
Gave up who I am for who you wanted me to be...
IDKSAF -RubinHighlander
Gave up who I am for who you wanted me to be...