Cursor movement to last cell with same number

S

Steven

I have some spreadsheets and several columns within them have only six or
seven possible values. Currently I scroll through these columns manually to
find the breaks between numbers.

Is there a cursor control to move the cursor to the last cell to have the
same number as in the cell the cursor currently resides on?

For example:

4097
4097
4097
4097
4098
4098
4098

If I'm currently on a 4097 cell, I would want to move down to the last
4097-valued cell.
 
S

Steven

I'm sorry, Bob, but I don't follow. I'm using Excel 2007, and can access
Find in two different ways:

1. CTRL-F. I've tried holding down the Shift while typing CTRL-F with no
luck.
2. Click on Find and Select from the main page. I've clicked on that, and
held down the Shift while clicking on Find, also with no luck.

What am I doing wrong?
 
D

Dave Peterson

So if your data were:

a
a
a
a
b
b
b
a
a
a

And you were on the second cell (the second a), you'd want to stop at the 4th
cell.

If that's the case, you could use a macro. You could assign the macro to a
shortcut key if you wanted, but I'd find it easier to rightclick and choose an
option.

If you want to try...

Create a new workbook (or maybe put it in your personal.xls* workbook???).

Option Explicit
Const myCaption As String = "Find Last In This Group Column"
Sub Auto_Open()
With Application.CommandBars("Cell")
On Error Resume Next
.Controls(myCaption).Delete
On Error GoTo 0
With .Controls.Add
.Caption = myCaption
.OnAction = "'" & ThisWorkbook.Name & "'!FindLastInGroup"
End With
End With
End Sub
Sub auto_close()
With Application.CommandBars("Cell")
On Error Resume Next
.Controls(myCaption).Delete
On Error GoTo 0
End With
End Sub
Sub FindLastInGroup()
If ActiveCell.Value = "" Then
'do nothing
Else
Application.ScreenUpdating = False
Do
If ActiveCell.Offset(1, 0).Value = ActiveCell.Value Then
If ActiveCell.Row = ActiveSheet.Rows.Count Then
Exit Do
Else
ActiveCell.Offset(1, 0).Activate
End If
Else
Exit Do
End If
Loop
Application.ScreenUpdating = True
End If
End Sub

Then save this workbook. Whenever you need this functionality, just reopen this
workbook.

You may want to add some other checks (no stopping on hidden rows????) -- or
anything else you can think of.

If you're new to macros:

Debra Dalgleish has some notes how to implement macros here:
http://www.contextures.com/xlvba01.html

David McRitchie has an intro to macros:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Ron de Bruin's intro to macros:
http://www.rondebruin.nl/code.htm

(General, Regular and Standard modules all describe the same thing.)
 
G

Gord Dibben

Find and Select from Home Tab

In the Find What dialog box enter 4097

Then hold SHIFT key and hit "Find Next"


Gord Dibben MS Excel MVP
 
S

Steven

Works like a charm! Thanks, guys!

Gord Dibben said:
Find and Select from Home Tab

In the Find What dialog box enter 4097

Then hold SHIFT key and hit "Find Next"


Gord Dibben MS Excel MVP
 

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