Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default need to select the next row every time a CommanButton is pressed

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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default need to select the next row every time a CommanButton is pressed

Hi,



"cj2k2k" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default need to select the next row every time a CommanButton is pressed

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

"cj2k2k" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 373
Default need to select the next row every time a CommanButton is pressed

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

"cj2k2k" wrote in message
...
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



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 18
Default need to select the next row every time a CommanButton is press

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.

"Zone" wrote:

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

"cj2k2k" wrote in message
...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Enter button jumps to next cell each time its pressed!!!! evasmagacz Excel Discussion (Misc queries) 3 June 17th 07 08:37 PM
Excel Only Showing # When £ has been pressed Gazz Excel Discussion (Misc queries) 12 December 5th 06 08:13 AM
preventing button being pressed Mike Excel Discussion (Misc queries) 2 March 16th 06 03:47 PM
count how many times a button is pressed Mike Excel Discussion (Misc queries) 2 February 5th 06 09:38 PM
Jump to data in a list as first letter is pressed Kiran Excel Discussion (Misc queries) 3 August 11th 05 08:53 AM


All times are GMT +1. The time now is 08:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"