Forum Discussion

Tony2021's avatar
Tony2021
Steel Contributor
Jun 18, 2021

Keyboard Shortcut for first Non Zero cell

Hello,

 

I have to navigate in a large data set and all of the cells have formulas. 

I am wondering if there is a key board shortcut to find the first cell, of the row I am on, that is non zero?   Control right arrow will not work. 

 

thank you

  • Tony2021 

    Make sure that you display the Developer tab of the ribbon.

    On this tab, click Macros.

    Enter FindNonZero in the Macro Name box, and click Create.

    Make the code look like this:

    Sub FindNonZero()
        Dim i As Long
        For i = 1 To 10000
            If ActiveCell.Offset(0, i).Value <> 0 Then
                ActiveCell.Offset(0, i).Select
                Exit For
            End If
        Next i
    End Sub

    Witch back to Excel.

    Click Macros again.

    Select FindNonZero and click Options...

    Click in the Shortcut key box.

    You can either enter a character or Shift+character. As a result you will assign Ctrl+character or Ctrl+Shift+character as shortcut. Try to avoid built-in shortcuts such ax Ctrl+C and Ctrl+S.

    Click OK.

    Save the workbook as a macro-enabled workbook.

    Make sure that you allow macros when you open it.

  • Tony2021 

    Make sure that you display the Developer tab of the ribbon.

    On this tab, click Macros.

    Enter FindNonZero in the Macro Name box, and click Create.

    Make the code look like this:

    Sub FindNonZero()
        Dim i As Long
        For i = 1 To 10000
            If ActiveCell.Offset(0, i).Value <> 0 Then
                ActiveCell.Offset(0, i).Select
                Exit For
            End If
        Next i
    End Sub

    Witch back to Excel.

    Click Macros again.

    Select FindNonZero and click Options...

    Click in the Shortcut key box.

    You can either enter a character or Shift+character. As a result you will assign Ctrl+character or Ctrl+Shift+character as shortcut. Try to avoid built-in shortcuts such ax Ctrl+C and Ctrl+S.

    Click OK.

    Save the workbook as a macro-enabled workbook.

    Make sure that you allow macros when you open it.

    • Tony2021's avatar
      Tony2021
      Steel Contributor
      thank you Hans. I was hoping for a keyboard shortcut. I am on a work computer and can not save macro enabled files unfortunately. I will keep the question open in case someone is aware of a key board shortcut.
  • klawr200's avatar
    klawr200
    Copper Contributor

    Tony2021 

    not a keyboard shortcut and may or may not work for your application but if you have headings, you can apply a filter and untick ‘0’ in its options.

Resources