Variables

F

Francis Hookam

Variables

I am using defined InsertionRow and InsertionCol variables to record row and
col in a spreadsheet

Is it possible to have a single variable, InsertionPoint, which will record
both Selection.Row and Selection.Column and use that to:

Cells(InsertionPoint).Select

or even

Cells.Insertion.Select

or am I expecting too much from something already amazing?

Francis Hookham
 
J

JE McGimpsey

Francis Hookam said:
Variables

I am using defined InsertionRow and InsertionCol variables to record row and
col in a spreadsheet

Is it possible to have a single variable, InsertionPoint, which will record
both Selection.Row and Selection.Column and use that to:

Cells(InsertionPoint).Select

or even

Cells.Insertion.Select

or am I expecting too much from something already amazing?

It might help to explain more what you're trying to do. Did you define
your own class with an Insertion property?

Normally one doesn't have to (and doesn't want to) select anything while
using VBA. Using range objects directly is faster, produces smaller
code, and is usually much easier to maintain.

That said, you can use a range object variable to capture the selection:

Dim rIP As Range
Set rIP = Selection

...

rIP.Select

to select the original selection, or

rIP(1).Select

to select the top-left call of the original selection.
 

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