ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Referring to a cell without using Offset (https://www.excelbanter.com/excel-programming/432711-referring-cell-without-using-offset.html)

Ayo

Referring to a cell without using Offset
 
Is there another way to refer to a cell that is in the same row and Column A
of the active cell. For example, let say Range("D8") is my activecell and I
want to refer to Range("A8"), how do I do that without using c.Offset(0,-3).

Thanks
Ayo

Jacob Skaria

Referring to a cell without using Offset
 
Do you mean the first column of the row. If then

Cells(activecell.Row,1)

OR
Cells(activecell.Row,"A")

Or
Range("A" & Activecell.row)


If this post helps click Yes
---------------
Jacob Skaria


"Ayo" wrote:

Is there another way to refer to a cell that is in the same row and Column A
of the active cell. For example, let say Range("D8") is my activecell and I
want to refer to Range("A8"), how do I do that without using c.Offset(0,-3).

Thanks
Ayo


Ayo

Referring to a cell without using Offset
 
I am sorry but I forgot to add a very important part, I am using a For...
Each... Next statement. My goal is: for very cell in Range("D2:D5") say, I
want to assign the values in column A, B and C of the same row to different
cells in another worksheet, for eaxmple using the following snippet of code:

For Each rc In marketWS.Range(hdrColumn & "5:" & hdrColumn &
marketWSlastRow).Cells
If rc.Interior.ColorIndex = 3 Then
pastdueWS.Range("A" & pastdueWS_currRow) = rc.Offset(0,
marName)
pastdueWS.Range("B" & pastdueWS_currRow) = rc.Offset(0, NLP)
pastdueWS.Range("C" & pastdueWS_currRow) = rc.Offset(0, -1)
pastdueWS.Range("D" & pastdueWS_currRow) = rc.Offset(0,
candID)
pastdueWS.Range("E" & pastdueWS_currRow) = milestoneTitle
pastdueWS.Range("G" & pastdueWS_currRow) = "p"
pastdueWS_currRow = pastdueWS_currRow + 1
End If
Next rc

I want to replace the rc.Offset with something more general.


"Jacob Skaria" wrote:

Do you mean the first column of the row. If then

Cells(activecell.Row,1)

OR
Cells(activecell.Row,"A")

Or
Range("A" & Activecell.row)


If this post helps click Yes
---------------
Jacob Skaria


"Ayo" wrote:

Is there another way to refer to a cell that is in the same row and Column A
of the active cell. For example, let say Range("D8") is my activecell and I
want to refer to Range("A8"), how do I do that without using c.Offset(0,-3).

Thanks
Ayo


Jim Thomlinson

Referring to a cell without using Offset
 
rc.parent.cell(rc.row, "A").value

gives you the value of Column A for the row that RC is on...
--
HTH...

Jim Thomlinson


"Ayo" wrote:

I am sorry but I forgot to add a very important part, I am using a For...
Each... Next statement. My goal is: for very cell in Range("D2:D5") say, I
want to assign the values in column A, B and C of the same row to different
cells in another worksheet, for eaxmple using the following snippet of code:

For Each rc In marketWS.Range(hdrColumn & "5:" & hdrColumn &
marketWSlastRow).Cells
If rc.Interior.ColorIndex = 3 Then
pastdueWS.Range("A" & pastdueWS_currRow) = rc.Offset(0,
marName)
pastdueWS.Range("B" & pastdueWS_currRow) = rc.Offset(0, NLP)
pastdueWS.Range("C" & pastdueWS_currRow) = rc.Offset(0, -1)
pastdueWS.Range("D" & pastdueWS_currRow) = rc.Offset(0,
candID)
pastdueWS.Range("E" & pastdueWS_currRow) = milestoneTitle
pastdueWS.Range("G" & pastdueWS_currRow) = "p"
pastdueWS_currRow = pastdueWS_currRow + 1
End If
Next rc

I want to replace the rc.Offset with something more general.


"Jacob Skaria" wrote:

Do you mean the first column of the row. If then

Cells(activecell.Row,1)

OR
Cells(activecell.Row,"A")

Or
Range("A" & Activecell.row)


If this post helps click Yes
---------------
Jacob Skaria


"Ayo" wrote:

Is there another way to refer to a cell that is in the same row and Column A
of the active cell. For example, let say Range("D8") is my activecell and I
want to refer to Range("A8"), how do I do that without using c.Offset(0,-3).

Thanks
Ayo


Ayo

Referring to a cell without using Offset
 
Thanks Jim. Works perfect.

"Jim Thomlinson" wrote:

rc.parent.cell(rc.row, "A").value

gives you the value of Column A for the row that RC is on...
--
HTH...

Jim Thomlinson


"Ayo" wrote:

I am sorry but I forgot to add a very important part, I am using a For...
Each... Next statement. My goal is: for very cell in Range("D2:D5") say, I
want to assign the values in column A, B and C of the same row to different
cells in another worksheet, for eaxmple using the following snippet of code:

For Each rc In marketWS.Range(hdrColumn & "5:" & hdrColumn &
marketWSlastRow).Cells
If rc.Interior.ColorIndex = 3 Then
pastdueWS.Range("A" & pastdueWS_currRow) = rc.Offset(0,
marName)
pastdueWS.Range("B" & pastdueWS_currRow) = rc.Offset(0, NLP)
pastdueWS.Range("C" & pastdueWS_currRow) = rc.Offset(0, -1)
pastdueWS.Range("D" & pastdueWS_currRow) = rc.Offset(0,
candID)
pastdueWS.Range("E" & pastdueWS_currRow) = milestoneTitle
pastdueWS.Range("G" & pastdueWS_currRow) = "p"
pastdueWS_currRow = pastdueWS_currRow + 1
End If
Next rc

I want to replace the rc.Offset with something more general.


"Jacob Skaria" wrote:

Do you mean the first column of the row. If then

Cells(activecell.Row,1)

OR
Cells(activecell.Row,"A")

Or
Range("A" & Activecell.row)


If this post helps click Yes
---------------
Jacob Skaria


"Ayo" wrote:

Is there another way to refer to a cell that is in the same row and Column A
of the active cell. For example, let say Range("D8") is my activecell and I
want to refer to Range("A8"), how do I do that without using c.Offset(0,-3).

Thanks
Ayo


Rick Rothstein

Referring to a cell without using Offset
 
rc.parent.cell(rc.row, "A").value

gives you the value of Column A for the row that RC is on...


Another way to return these same value...

rc.EntireRow.Cells(1).Value

--
Rick (MVP - Excel)


All times are GMT +1. The time now is 12:57 AM.

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