Code on button how?

  • Thread starter Thread starter Pieter geerts
  • Start date Start date
P

Pieter geerts

I want the following code attach to a commandbutton.

Sub Rij_Invoegen()
ActiveCell.Offset(1, 0).EntireRow.Insert
End Sub

I wont get it working. I want to insert a row under the row i select.
 
If you use a commandbutton (a commandbutton is from the control toolbox
toolbar), just double click on it and you'll see where the code goes. You'll
just copy|paste that single line--it'll already have the name of the sub and the
End sub line.

If you used a button from the Forms toolbar, you could put your code in a
General module--not behind the worksheet, not behind ThisWorkbook and then
rightclick on that button and choose assign macro.

If you're gonna use this same code for buttons on lots of worksheets, I'd use
the forms button. Each of these forms button can have the same macro assigned
to it.

With commandbuttons, you'll be duplicating the code for each button.
 
Back
Top