Excel shortcut to open to specific sheet


  1. Posts : 481
    Windows 10 pro 1903 1862.145
       #1

    Excel shortcut to open to specific sheet


    I have a shortcut to open Excel to a file: "C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE" c:\all\Workbooks\General.xlsm". Is there a way to specify the sheet? I tried adding the sheet name to the end of the shortcut but I get an error comment.
      My Computer


  2. Posts : 30,198
    Windows 11 Pro x64 Version 23H2
       #2

    Have you googled "Open excel workbook on specific sheet"? Couple of examples.

    Seems you have to have macros enabled which is a security risk.

    One such example which even allows you to target cell.

    Easy steps to open an Excel workbook to a specific worksheet

    I have not tried.

    Ken
      My Computer


  3. Posts : 481
    Windows 10 pro 1903 1862.145
    Thread Starter
       #3

    'Preciate that , Ken, but I did google the question and encountered that entry. The operative word is "shortcut". There are several sheets that I might want to open to and I envision several shortcuts, one for each sheet. Maybe set up in Hotkeyp or Autohotkey.
      My Computer


  4. Posts : 30,198
    Windows 11 Pro x64 Version 23H2
       #4

    Yes saw the word shortcut but as sheet is not a parm that can be feed with start, at least that I know of, it was next best thing.

    A program that could emulate key strokes very well could work. I will be interest in your results.

    Actually you could also likely break this down into individual input files that represent the actual sheets. Each file acting as an input sheet. Then have one central workbook (file) that gets all its values through formulas referencing the individual files. You wouldn't actual enter data into this summary workbook, it would just be a summary of all the individual files. Huge amount of work to set up.
      My Computer


  5. Posts : 481
    Windows 10 pro 1903 1862.145
    Thread Starter
       #5

    OK, I hear you. Think I'll get along without separate shortcuts and keep all the sheets together, as they are.

      My Computer


  6. Posts : 17,838
    Windows 10
       #6

    What about jump lists?
      My Computer


  7. Posts : 1,482
    W10 22H2 19045.3031
       #7

    I have a couple of spread sheets sitting on my desktop [name for the file]. I just double click any one and excel opens with that file. While holding down the [shift] key you can select multiple sheets and they will all open.
      My Computers


  8. Posts : 1
    W10Pro
       #8

    Ok, I've just done this today.
    Excel cant' read command line parameters but it can read environment variables..

    I created a VBS script which sets an environment variable with the cell address that you want - this is passed as a command line parameter to the scrip so that you can change it with each shortcut that you have.

    ExcelB.vbs:
    ' Starts Excel, opens a file and passes a parameter to Excel via environment variable
    ' Syntax: ExcelB.vbs FileName Parameter

    'Write to environment variable - from the 2nd command line parameter: Item(1)
    'Set objShell = WScript.CreateObject("WScript.Shell")

    objShell.Environment("PROCESS").Item("ExcelParam") = WScript.Arguments.Item(1)

    'open Excel with the filename passed from the 1st command line parameter: Item(0)
    Set objShell = CreateObject ("WScript.Shell")
    Set objExec = objShell.Exec ("C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE " & WScript.Arguments.Item(0))

    In Excel, create VBA code to read the environment variable and goto the desired cell
    Private Sub Auto_Open()
    Dim sParam As String,
    Dim sCell As String
    Dim sCellR1 As String

    sParam = Environ("ExcelParam")

    If Left(sParam, 1) = "#" Then
    sCell = Mid(sParam, 2, 200)
    sCellR1 = Application.ConvertFormula(sCell, xlA1, xlR1C1)
    Application.Goto sCellR1
    End If
    End Sub

    I've designated a '#' symbol as a trigger for "goto a cell", so that other commands could be added if required
    This is also in keeping with MS standards (if you create a hyperlink to a cell in Excel and then examine the hyperlink you will see that it uses this same format)

    Lastly, you'll need to create Shortcuts in Windows File Explorer with the following format for the 'Target' setting in the shortcut:
    C:\ExecelB.vbs C:\testfile.xlsm #Sheet2!A3

    And there you have it - Windows Shortcuts which will open an Excel spreadsheet to a specific sheet/cell

    The only condition is that the Excel spreadsheet must not be already open.
    I'm sure someone could improve on this to make it also work if the file is open.

    Hope this helps

    regards, Phil (in Australia)
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 17:45.
Find Us




Windows 10 Forums