Data Validation list assistance

47 views
Skip to first unread message

Ramon Corrales

unread,
Jun 17, 2021, 12:53:52 PM6/17/21
to Google Apps Script Community
Team

I have a drop down list using Data Validation, of course.  Is it possible to use scripting to increase the size of the list items?

If so, can someone provide coding ?

Here is my code, so far.

the setFontSize(15)....  only increases the size of the item I select.
-----------------------------------------------------------------------------------------------------------------------

function myFunction() {
 
  var ss = SpreadsheetApp.getActiveSpreadsheet();
 
  var menuSheet = ss.getSheetByName("menu");
  var namesSheet = ss.getSheetByName("names");
 
  var namesCell = menuSheet.getRange('A1');
  var namesLastRoll = namesSheet.getLastRow();
  var namesRange = namesSheet.getRange('A1:A'+ namesLastRoll);
  var namesRule = SpreadsheetApp.newDataValidation().requireValueInRange(namesRange).build();
      namesCell.setDataValidation(namesRule).setFontSize(15);
     
     








Ramon Corrales

Workforce Manager

Experience Center & Learning Space Services

University Technology Office

Arizona State University

Mail Code: 6504

1150 E University Dr. Suite 115

Tempe, AZ 85281

p: 855-278-5080 

email: ramon.c...@asu.edu

web: uto.asu.edu

 linkedin 


ASU #1 in the U.S. for innovation

 



Clark Lind

unread,
Jun 18, 2021, 9:01:57 AM6/18/21
to Google Apps Script Community
Might be much simpler than you are making it.. lol  

Instead of tacking it onto the validation builder, just call it separately. See if this works. If it does, then I'm guessing it might be trying to set the font size before the validation has been completed.
      namesCell.setDataValidation(namesRule);
      namesCell.setFontSize(15);

Laurie Nason

unread,
Jun 20, 2021, 6:00:36 AM6/20/21
to google-apps-sc...@googlegroups.com
Hi,
  • Not sure if this will help, but I always try to use named ranges down a whole column for validations - e.g. A2:A - normally this gives me by default 1000 potential options for the dropdown - but will only show the non-blank items - so it doesn't matter if you have blanks in the list.
  • Have a separate hidden settings sheet where I can SORT(UNIQUE(my sheet column with the values I want to use for my dropdown)) 
  • I have also used a UNIQUE(QUERY()) statement as well when I want to only use a subset of the values in a column or I select two columns and then have an ARRAYFORMULA in the next column to TextJoin them together to produce the values I want to get in my dropdown e.g. firstname and last name with a space to be able to select a full name.
  • If you really want to get fancy and trust your users not to put something stupid into the column, you can even opt to not restrict the data validation values to something in the list and use the Unique on the values the user enters on the settings sheet to automatically add the users entry to the dropdown list for the next person to select. (I have done this, but rarely! Users tend to not check if the option they want to use already exists and then will type the same thing again, but mis-spell, abbrieviate, capitalise differently.... and my list could go on for a long time - so my advice is definitely take this option under advisement.
  • I can even have some values at the top of the column on the settings sheet if I need to manually add something to the top of the drop down list e.g. "Unknown" 
  • I will use the Named Range feature to set up a list e.g. Settings!A2:A to something useful like "Result_Options" and then apply the validation to the column the user is going to be selecting a value in on the main sheet.
So far in my 5 years of doing this, I haven't had to resort to coding the data validation - which I am happy with!
If you need anything more, just reply and I will be happy to elaborate.
Laurie

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/4e36af7d-ba7e-4d82-9ff6-a4291f9c8ed0n%40googlegroups.com.


--

Laurie Nason 

The KAUST School – Operational Analyst

Information Technology Support
Deep in the Bowels of the School
Landline: +966-12-808-6853

Reply all
Reply to author
Forward
0 new messages