Page 1 of 1

[Solved] Macro to hide cells based on outcome

Posted: Tue Mar 07, 2017 7:00 pm
by jcc1981
So, I've been tasked with creating an automated calculation for my work. I'm not a novice at excel, but I am with macros.

Ideally, I'd like for cells to be hidden based on the three possible outcomes determined in cell D39 [=IF(B36>E9,"MOVE TO PWD DISBURSEMENT TRACKING SHEET",IF(E9=B36,"STOP! NO FURTHER ACTION NECESSARY",IF(B36<E9,"MOVE TO STEP 4. Aid to be Disbursed or Returned")))]

If "MOVE TO PWD DISBURSEMENT TRACKING SHEET" - Rows 42-82 should be hidden
If "STOP! NO FURTHER ACTION NECESSARY" - Rows 42-103 should be hidden
If "MOVE TO STEP 4. Aid to be Disbursed or Returned" - Rows 83-103 should be hidden

Any help you can provide would be GREATLY appreciated!! :D

Jason

Re: Macro to hide cells based on outcome

Posted: Tue Mar 07, 2017 7:29 pm
by JeJe
Hide cell contents in Calc Spreadsheets:

viewtopic.php?f=101&t=54749

If you're after help with Excel, this forum maybe:

http://www.vbforums.com/forumdisplay.ph ... evelopment

Re: Macro to hide cells based on outcome

Posted: Tue Mar 07, 2017 10:41 pm
by MrProgrammer
Hi, and welcome to the forum.
jcc1981 wrote:I'd like for cells to be hidden based on the three possible outcomes determined in cell D39
If you want cell contents conditionally hidden, use Format → Conditional Formatting and a cell style which specifies number format ;;; (three semicolons).

But your explanation suggests that you want rows to be hidden, not cells. The standard way in Calc to hide cells is with a filter. Data → Filter → Advanced filter will do what you need without the need for evil macros. Open the attachment. Change either B36 or E9. The text in D39 will change accordingly. To hide the desired rows, click A41 and use Data → Refresh Range.

If you need the latter actions automated, use Tools → Macros → Record Macro to record clicking A41 and refreshing. Also see [Tutorial] Binding a macro: Shortcut key, menu or toolbar.

If you want the rows to hide/unhide automagically, without a range refresh see [Tutorial] Sorting and Filtering data with formulas.

Read about conditional formatting and/or recording macros in Help → Index or in User Guides (PDF) or searching for topics about them in the Calc Forum.

[Tutorial] Ten concepts that every Calc user should know

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.

Re: Macro to hide cells based on outcome

Posted: Tue Mar 07, 2017 11:05 pm
by jcc1981
Thanks for the information!!