ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   2B or not 2B? - Go to cell Bx, depending on what row is selected (https://www.excelbanter.com/excel-programming/388007-2b-not-2b-go-cell-bx-depending-what-row-selected.html)

bony_tony

2B or not 2B? - Go to cell Bx, depending on what row is selected
 
Hi,
I'm no vba programmer, I can record macros, do loops etc, but I'm not
sure how/why each statement is structured the way it is.
What I want to do is store the value from a specific cell. The cell
is located in column B, and in the row of the current selection. ie,
if cell J23 is selected, I want to store the value of J2 as i. If A1
is the current selected cell, then it should be A2 which is stored as
i...

From trying to figure it out myself, i've got

i = Cells(Row.Selection, 2)
Can someone tell me where I'm going wrong?

Cheers


Halim

2B or not 2B? - Go to cell Bx, depending on what row is selected
 
try this :
i Cells(Selection.Row, 2)

Regards,

Halim


"bony_tony" wrote:

Hi,
I'm no vba programmer, I can record macros, do loops etc, but I'm not
sure how/why each statement is structured the way it is.
What I want to do is store the value from a specific cell. The cell
is located in column B, and in the row of the current selection. ie,
if cell J23 is selected, I want to store the value of J2 as i. If A1
is the current selected cell, then it should be A2 which is stored as
i...

From trying to figure it out myself, i've got

i = Cells(Row.Selection, 2)
Can someone tell me where I'm going wrong?

Cheers



JE McGimpsey

2B or not 2B? - Go to cell Bx, depending on what row is selected
 
One way:

i = Cells(ActiveCell.Row, 2).Value


In article .com,
bony_tony wrote:

Hi,
I'm no vba programmer, I can record macros, do loops etc, but I'm not
sure how/why each statement is structured the way it is.
What I want to do is store the value from a specific cell. The cell
is located in column B, and in the row of the current selection. ie,
if cell J23 is selected, I want to store the value of J2 as i. If A1
is the current selected cell, then it should be A2 which is stored as
i...

From trying to figure it out myself, i've got

i = Cells(Row.Selection, 2)
Can someone tell me where I'm going wrong?

Cheers



All times are GMT +1. The time now is 02:39 PM.

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