Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

I'm looking fSSearch bar look for partial matches including letters and special characters

$
0
0

really finding it hard to obtain a script that does this. I've created a spreadsheet that has a data entry form 'User Form' referring to another sheet that is where the data is submitted to 'Database' row 3 is my 'job id' however this isn't always just numbers (eg. 111499B or DCWP3P00045 etc. ) is there away to change the script so when the script runs it searches row 3 for the closest job id (not necessarily an exact match) or at least the letters, numbers and special characters. Below is the script I currently have which is fine to find 111499 (if that's the number in row 3) however it won't find 111499 if a letter is added.

//Function to Search the recordfunction searchRecord() {  var myGoogleSheet=SpreadsheetApp.getActiveSpreadsheet(); //declare a variable and set with active google sheet   var shUserForm=myGoogleSheet.getSheetByName("User Form"); //declare a variable and set with the User Form reference  var datasheet=myGoogleSheet.getSheetByName("Database"); ////declare a variable and set the reference with the Database worksheet  var str=shUserForm.getRange("C3").getValue();  var values=datasheet.getDataRange().getValues(); //getting the entire values from the used range and assigning it to values variable  var valuesFound=false; //variable to store boolean value  for (var i=3; i<values.length; i++)     {    var rowValue=values[i]; //declare a variable and storing the value    //checking the first value of the record is equal to search item    if (rowValue[3]==str){      shUserForm.getRange("C7").setValue(rowValue[0]) ;      shUserForm.getRange("C10").setValue(rowValue[1]);      shUserForm.getRange("D10").setValue(rowValue[2]);      shUserForm.getRange("C13").setValue(rowValue[3]);      shUserForm.getRange("C16").setValue(rowValue[4]);      shUserForm.getRange("C19").setValue(rowValue[5]);      shUserForm.getRange("C22").setValue(rowValue[6]) ;      shUserForm.getRange("C25").setValue(rowValue[7]) ;      shUserForm.getRange("C28").setValue(rowValue[8]) ;      shUserForm.getRange("E28").setValue(rowValue[9]) ;      shUserForm.getRange("C30").setValue(rowValue[10]) ;      shUserForm.getRange("E30").setValue(rowValue[11]) ;      shUserForm.getRange("C33").setValue(rowValue[12]) ;      shUserForm.getRange("E33").setValue(rowValue[13]) ;      shUserForm.getRange("C36").setValue(rowValue[14]) ;      shUserForm.getRange("E36").setValue(rowValue[15]) ;      shUserForm.getRange("C39").setValue(rowValue[16]) ;      shUserForm.getRange("B44").setValue(rowValue[17]) ;      shUserForm.getRange("C44").setValue(rowValue[18]) ;      shUserForm.getRange("D44").setValue(rowValue[19]) ;      shUserForm.getRange("E44").setValue(rowValue[20]) ;      valuesFound=true;      return; //come out from the search function  }    }if(valuesFound==false){  //to create the instance of the user-interface environment to use the alert funcion  var ui=SpreadsheetApp.getUi();  ui.alert("no record found!"); }}

Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>