Google Sheets - trying to make it so clicking a button navigates to a certain cell and brings that cell to the top of the screen

cTatch

New Member
Joined
Jan 21, 2021
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I'm trying to figure out how to make it so that when I click a button that I created in Google Sheets, it takes me to the cell I told it to (via the code below) and brings that cell to the top of my sheet in terms of viewing. I don't know code, but I found the code below online for the navigation, which works great, except that it navigates to where the top of the table is at the very bottom of the page (see attached image). I'd like to find a way to where it navigates to the same cell, but it brings it up to the top of the page - is there a way to do this? Thank you

Thank you in advance.

function FUNDEDANDAWARDRECEIVEDCVM(){
// 1 = row 1, 14 = column 14 = N
goToSheet("FY22 STATUS", 3, 2);
}
function goToSheet(sheetName, row, col) {
var sheet = SpreadsheetApp.getActive().getSheetByName(sheetName);
SpreadsheetApp.setActiveSheet(sheet);
var range = sheet.getRange(row, col)
SpreadsheetApp.setActiveRange(range);
}
 

Attachments

  • Screenshot 2021-07-20 170350.png
    Screenshot 2021-07-20 170350.png
    237.3 KB · Views: 35

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I don't know about Google Sheets ... but this works in Excel :


VBA Code:
Option Explicit

Sub GoToCell()
    Range("D5").Select  'edit cell accordingly
    Application.Goto ActiveCell
End Sub
 
Upvote 0
Thanks Logit, I couldn't get that one to work though - what about this below? I found it on this site. I'm thinking it might work for what I'm looking to do, but I'm not sure how to get that into Google Sheets code, does anyone know how to translate the below XLS code for use in Google Sheets? Thank you.

Sub TopLeft()
Application.Goto ActiveCell, Scroll:=True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top