excel macro enter key

0

I try to make a macro run by pressing Enter . The idea is that when you press the Enter key, create a new row with a auto-numeric value. The problem is that when recording the macro, it takes the ranks . Is there any way for the macro to always jump to the cell in the first column of the next row to the current one? And to execute it with the Enter key? Thanks.

    
asked by Juan 23.05.2018 в 16:00
source

1 answer

1

This code will insert the formula FILA()-7 in column A, and automatically select the adjacent cell in column B. I have played with column A and B but adapt the code to your needs:

Sub NUEVA_FILA()
Range("A" & (Range("A" & Range("A:A").Count).End(xlUp).Row) + 1).FormulaR1C1 = "=ROW()-7"
Range("B" & (Range("A" & Range("A:A").Count).End(xlUp).Row)).Select
End Sub

This is what I get by running the code several times.

Now, my macro is not assigned to any key or keyboard shortcut. I have done it by inserting a button (ActiveX control) on the sheet, and when I click, it executes the macro.

  

To learn more about inserting buttons in sheets, click   here

    
answered by 28.05.2018 в 11:18