insering rows with vb

K

katie

Hi
This piece of code inserts a new row on the current
worksheet, above the active cell.




Private Sub CommandButton1_Click()

ActiveCell.Resize(1, 1).EntireRow.Insert

End Sub



Anyone know how this can be expanded to insert a new row
in exactly the same position on worksheet 2?
Many Thanks
katie
 
N

Nikos Yannacopoulos

Katie,

Here it goes:

Worksheets("Sheet2").Rows(ActiveCell.Row).EntireRow.Insert

HTH,
Nikos
 
D

DNF Karran

Private Sub CommandButton1_Click()

Dim loRow
loRow = ActiveCell.Row

Activesheet.Range(loRow & ":" & loRow).Insert
Sheets(2).Range(loRow & ":" & loRow).Insert

End Su
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top