ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Offset indeterminate amount (https://www.excelbanter.com/excel-programming/446945-offset-indeterminate-amount.html)

robzrob

Offset indeterminate amount
 
Hello

I have a cell selected, but I don't know where it will be and I want to go from it to the cell which is in the same row but in column M. Because of this, I can't use OFFSET(Y,X), because I won't know what X and Y will need to be.

Cheers

Auric__

Offset indeterminate amount
 
robzrob wrote:

I have a cell selected, but I don't know where it will be and I want to
go from it to the cell which is in the same row but in column M.
Because of this, I can't use OFFSET(Y,X), because I won't know what X
and Y will need to be.


Since it's *always* column M, you can hardcode that bit of info into your
formula/code.

As a spreadsheet formula, you could do something like this:
=INDIRECT(ADDRESS(ROW(),13))
(But test & adjust that to suit your needs; I'm not very good with
spreadsheet functions.)

In VBA, I'd probably do this:
Cells(ActiveCell.Row, 13).Select

For both VBA and spreadsheet formulae there are other ways; you might want to
do some investigating. Open the "insert function" dialog and search for
"offset" to start.

--
The cinema is not a slice of life but a piece of cake.

robzrob

Offset indeterminate amount
 
On Sunday, 26 August 2012 20:17:59 UTC+1, Auric__ wrote:
robzrob wrote:



I have a cell selected, but I don't know where it will be and I want to


go from it to the cell which is in the same row but in column M.


Because of this, I can't use OFFSET(Y,X), because I won't know what X


and Y will need to be.




Since it's *always* column M, you can hardcode that bit of info into your

formula/code.



As a spreadsheet formula, you could do something like this:

=INDIRECT(ADDRESS(ROW(),13))

(But test & adjust that to suit your needs; I'm not very good with

spreadsheet functions.)



In VBA, I'd probably do this:

Cells(ActiveCell.Row, 13).Select



For both VBA and spreadsheet formulae there are other ways; you might want to

do some investigating. Open the "insert function" dialog and search for

"offset" to start.



--

The cinema is not a slice of life but a piece of cake.




Thank you, that looks as though it will do very well.


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

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