ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping (https://www.excelbanter.com/excel-programming/339541-looping.html)

Steve

Looping
 
I want to start in cell A1 and each time I click a button on a userForm I
want the cursor to move to the next cell, in this case, a2. Then, if the
cursor is in a2, when the button is clicked again, I would like the cursor to
move to a3.

Any ideas?

Thanks,

JE McGimpsey

Looping
 
One way:

Private Sub CommandButton1_Click()
With Selection
If .Row + .Rows.Count = .Parent.Rows.Count Then
.Parent.Cells(1, .Column).Resize( _
.Rows.Count, .Columns.Count).Select
Else
.Offset(1, 0).Select
End If
End With
End Sub


In article ,
"Steve" wrote:

I want to start in cell A1 and each time I click a button on a userForm I
want the cursor to move to the next cell, in this case, a2. Then, if the
cursor is in a2, when the button is clicked again, I would like the cursor to
move to a3.

Any ideas?

Thanks,


Charlie

Looping
 
Try:

If ActiveCell.Row < 65536 Then Cells(ActiveCell.Row + 1,
ActiveCell.Column).Select


"Steve" wrote:

I want to start in cell A1 and each time I click a button on a userForm I
want the cursor to move to the next cell, in this case, a2. Then, if the
cursor is in a2, when the button is clicked again, I would like the cursor to
move to a3.

Any ideas?

Thanks,



All times are GMT +1. The time now is 06:34 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com