Go with use of a macro to other sheet and in the table in this sheet, go to first empty row

Copper Contributor

Hello,

 

 i want to try to create a macro and connect this to a command button. As an employee clicks on this button, the cursor needs to go to the a specifc sheet (f.e. Bezoeken) and in the table in that specific sheet, the cursor needs to go to the first empty row (row A15) of this example.

 

Diana1005_0-1712839064521.png

 

After the employee has filled in his/her data, saved it and closed the file, the cursor must go to the wollowing next free row of this sheet when another employee opens this file.

 

I have tried several things, but nothing will work and lets the cursor go to the first empty row. 

 

Hopefully someone can help me.

 

Thank you for your reply and your help.

 

With regards,

Diana 

4 Replies

@Diana1005 

For example:

Sub GoToNextRow()
    With Worksheets("Bezoeken")
        Application.Goto Reference:=.Range("A" & .Rows.Count).End(xlUp).Offset(1), Scroll:=True
    End With
End Sub

If you want the next available cell to be selected automatically when the workbook is opened:

In the Visual Basic Editor, in the Project Explorer pane on the left, double-click ThisWorkbook (under Microsoft Excel Objects).

Copy the following code into the ThisWorkbook module:

Private Sub Workbook_Open()
    Call GoToNextRow
End Sub

@HansVogelaar 

Thank you for your quick response.

 

It almost works. But the Sheet "Bezoeken"contains a table and with your code 

Call GoToNextRow

Excel goes automatically to the last row of the table and not to the first available empty cell in the first empty row even when it is in a table. 
Is that also possible to create? That when Excel opens, that Excel automatically goes to the first empty cal in the first empty row even this row is in a table?

Diana1005_0-1712911330393.png

So everytime someone filles in data in a row and Excel saves automatically the data or the Excel worksheet will be closed, and Excel will be started again, that the cursor goes to the first available cell in the first empty row in the sheet?

 

Hopefully that is possible.

 

Looking forward to your reply.

 

With regards,
Diana

@Diana1005 

Try this version:

Sub GoToNextRow()
    Application.Goto Reference:=Worksheets("Bezoeken").Range("A1").End(xlDown).Offset(1), Scroll:=True
End Sub
Hoi Hans,

thank you for your help. It works.

With regards, (Groetjes)
Diana