MOVING WITH A RANGE-TAB

  • Thread starter Thread starter FARAZ QURESHI
  • Start date Start date
F

FARAZ QURESHI

What would be the appropriate piece of code for using the feature of TAB,
within a selected range.
 
<<What would be the appropriate piece of code for using the feature of TAB,
within a selected range.>>

Why not just use the Tab key?

If you are developing some kind of demo where the user watches the display
demonstrate various concepts, then you might use the following:

Application.SendKeys "{TAB}"

To select another cell adjacent to the currently active cell without
changing the current selection, you could use code similar to the
following:

ActiveCell.Offset(0, 1).Activate 'Move right one cell.

ActiveCell.Offset(1, 0).Activate 'Move down one cell.
 
Sorry Bill,

But after selecting a lenghty range, usually with mouse, I shift to the LAST
cell with SHIFT+TAB, or even CTRL+"." twice. Whereas your code only moves
step by step.

Would you kindly recommend me a piece of code for moving to the last cell
selected in the range?
 
<<...your code only moves step by step.>>

That's what TAB does.

<<Would you kindly recommend me a piece of code for moving to the last cell
selected in the range?>>

To move to the last cell in a selection, regardless of whether it has data
in it or not, try the following:

'----------------------------------------------------------------------
Public Sub ActivateLastCellInSelection()
Dim rngSelection As Range
Dim rngLastCell As Range

On Error GoTo ExitSub

Set rngSelection = Selection

With rngSelection
Set rngLastCell = .Resize(1, 1) _
.Offset(.Rows.Count - 1, _
.Columns.Count - 1)
rngLastCell.Activate
End With

ExitSub:
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

Back
Top