+ Reply to Thread
Results 1 to 2 of 2

Drop down and hide unhide rows

Hybrid View

  1. #1
    Registered User
    Join Date
    02-18-2023
    Location
    Oklahoma
    MS-Off Ver
    googlesheets
    Posts
    15

    Drop down and hide unhide rows

    I have a spreadsheet with close to two dozen buttons that seem to relocate from time to time

    I am wondering if I remove the buttons can a index for rows be pulled for the sheet

    replace the buttons in a particular cell C7 C14 c18 for example and then hide and unhide rows based on the drop down list in those cells

    this might enable me to setup if and or if else statements in a single function based on the particular cell and its value to hide and unhide these rows and get rid of my button problem at the same time

    thanks for any insight

  2. #2
    Registered User
    Join Date
    02-18-2023
    Location
    Oklahoma
    MS-Off Ver
    googlesheets
    Posts
    15

    Re: Drop down and hide unhide rows

    So I got this to work off my drop down selection box.

    I am sure I can use the getRowByIndex to open hide or unhide a range of rows but am unsure how to get this done


    function buttonTwo(e) 
    {
      var myGooglSheet    = SpreadsheetApp.getActiveSpreadsheet(); 
      var ui              = SpreadsheetApp.getUi();
      const ss            = SpreadsheetApp.getActive();
      const sourceSheet   = ss.getSheetByName("Admin Dashboard");                                                               
      const sheet         = ss.getSheets()[0];
      
      //const getRowByIndex = (index) => currentSheet.getRange(`${index}:${index}`)
    
      //var rows = ssourceSheetheet.getRange(from, 18, where, 19).getValues();
    
      if (!(e.range.getA1Notation() == 'C9' && e.range.getSheet().getName() == 'Admin Dashboard')) { return }  
    
      var c = sourceSheet.getRange("C9").getValue(); 
    
      if ( ["Open", "Close"].indexOf(c) == -1 ) return
     
      if ( c == "Open" )
      {
        if (ui.alert( "Open 2 Detected", ui.ButtonSet.OK_CANCEL) == ui.Button.CANCEL ) return 
        {
        sourceSheet.showRows('18');
        sourceSheet.showRows("19"); 
        }  
      }
      else  
      if ( c == "Close" )
      {
        if (ui.alert( "Close 2 Detected", ui.ButtonSet.OK_CANCEL) == ui.Button.CANCEL ) return 
        {
        //sourceSheet.hideRows('18','19'); this closes 18 thru 37 this wont work
    
        sourceSheet.hideRows('18'); // these work but i want to combine them into one variable
        sourceSheet.hideRows('19');
        }  
      }  
    }

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. help please - hide unhide rows and columns based on drop down selection
    By iamgujju in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 07-01-2019, 10:56 AM
  2. [SOLVED] Auto Hide/Unhide Rows Anytime Drop Down List Changes
    By jkle4596 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 10-01-2015, 10:02 AM
  3. Hide/Unhide Rows Based On Drop Down Selection
    By QABrian in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-14-2014, 11:53 PM
  4. Hide-Unhide rows on multiple worksheets based on value of a drop down list
    By clo2peter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-10-2014, 08:32 AM
  5. [SOLVED] hide or unhide rows based on text within a drop down list
    By souimet in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2013, 01:32 AM
  6. [SOLVED] How to hide & unhide rows based on selection from drop down box?
    By jgomez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-02-2013, 08:30 PM
  7. Replies: 1
    Last Post: 02-01-2013, 03:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1