need to select the next row every time a CommanButton is pressed

G

Guest

I need to select the next row every time a CommanButton is pressed.
I need to start with row3, select it and copy it. The next time the
CommanButton is pressed, it will select the next and copy the next row (Row4)
and so on everytime the CommandButton is pressed.

This is what I have put together so far, but its not working.

Private Sub CommandButton1_Click()
Rows("2:2").Select
Cells(.Row + 1, 1).Select
Selection.Copy
End Sub
 
G

Guest

You don't say what you want to do with the copied data so this simply select
rows.
Start with a 3 in A1 (or any other cell you want) and use this

Sub Button2_Click()
myrow = Sheets("Sheet1").Range("A1").Value
Rows(myrow & ":" & myrow).Select
Selection.Copy
'Do your stuff
Sheets("Sheet1").Range("A1").Value = myrow + 1
End Sub

Mike
 
Z

Zone

Select a cell in row 1 before clicking the button the first time. Then,
this should work:

Private Sub CommandButton1_Click()
Rows(Selection.Row+1).Select
Selection.Copy
End Sub

HTH, James
 
G

Guest

Thank all for helping me.
this works great, I just have to have row 3 pre-selected when this file is
opened and it will work.
 

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