ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to get row number from R[4]C (https://www.excelbanter.com/excel-programming/375403-how-get-row-number-r%5B4%5Dc.html)

Goofy

How to get row number from R[4]C
 
I need to get the integer value from the address R[4]C, any ideas ?








Dave Peterson

How to get row number from R[4]C
 
I'm not quite sure how you got this string, but this worked ok for me:

Option Explicit
Sub testme()
Dim myStr As String
Dim OpenBrktPos As Long
Dim CloseBrktPos As Long
myStr = "R[433]C"

OpenBrktPos = InStr(1, myStr, "[", vbTextCompare)
CloseBrktPos = InStr(1, myStr, "]", vbTextCompare)

Debug.Print Mid(Left(myStr, CloseBrktPos - 1), OpenBrktPos + 1)

End Sub


But =r[4]c means that it's 4 rows down from the cell containing that formula (in
the same column).

Goofy wrote:

I need to get the integer value from the address R[4]C, any ideas ?


--

Dave Peterson

Dave Peterson

How to get row number from R[4]C
 
myStr = "R[433]C"
was really
myStr = "R[4]C"
On my first test.


Dave Peterson wrote:

I'm not quite sure how you got this string, but this worked ok for me:

Option Explicit
Sub testme()
Dim myStr As String
Dim OpenBrktPos As Long
Dim CloseBrktPos As Long
myStr = "R[433]C"

OpenBrktPos = InStr(1, myStr, "[", vbTextCompare)
CloseBrktPos = InStr(1, myStr, "]", vbTextCompare)

Debug.Print Mid(Left(myStr, CloseBrktPos - 1), OpenBrktPos + 1)

End Sub

But =r[4]c means that it's 4 rows down from the cell containing that formula (in
the same column).

Goofy wrote:

I need to get the integer value from the address R[4]C, any ideas ?


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 09:19 AM.

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