Creating a code for a macro

E

engbe

Hi, Can any one please help me with writing a code in visual basics?

What i am trying to do is this:
I want to create a button called 'close' in row 1(sheet 1) and when I click
this I want a marco to run which will delete the entire row that the button
is on and then paste that row into row 5 in worksheet 2. I want to repeat
this for the next row however, when the second row is pasted into worksheet 2
i want the second row to be pasted in row 5 and the first row move down to
row 6...

I hope this makes sense and would really appreciate any assistance from
anyone as i am not to familiar with writing up codes...THANK YOU in advance!
 
D

Don Guillett

One way. Use ONLY one button and select the row first.

Sub movelastrowtoothersheet()
With Sheets("sheet2")
dlr = .Cells(Rows.Count, "a").End(xlUp).Row + 1
'MsgBox dlr
slr = ActiveCell.Row
'if you always want it to be the LAST row use this line instead
'slr = Cells(Rows.Count, "a").End(xlUp).Row
'MsgBox slr
Rows(slr).Copy .Cells(dlr, "a")
Rows(slr).Delete
End With
End Sub
 

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