Skip to main content
2 of 2
deleted 59 characters in body

How to Jump to Column Based off of Cell Value

My expected result is very simple - I have used data validation to place a list of column titles in a cell. When a user selects a column title and clicks the button, I want them to be taken to the COLUMN where that word is the title.

For example, user selects "Game 5", which is in column 34. They click "JUMP" and are taken to Column 34 Row 1.

Likewise, user selects "Game 52", which is in column 76. User clicks "JUMP" button and is taken to Column 76 Row 1.

Here's what I have so far:

MATCH function set up in Cell AP1, searching for the dropdown value location within the top row. This basically returns the Column # that I want the jump button to move to.

Then, I have my script:

function jump2() {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var s = ss.getSheetByName("ClassicGames"); // change to sheet containing dates
      var r = s.getRange("AP1").getValue(); //change A1 to cell containing =match formula
      s.setActiveSelection(s.getRange(r)); 
}

I thought maybe this combination would just take me to whatever number the MATCH function finds. For instance, if r = 35, the user will move to the 35th column.