ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   obtaining the collumn letter and row number separately (https://www.excelbanter.com/excel-programming/421342-obtaining-collumn-letter-row-number-separately.html)

Sean Farrow

obtaining the collumn letter and row number separately
 
Hi:
Isthere a way to obtain the collumn letter (A) for example and hte row
number (2) as separate variables.
Any help apreciated.
Sean.



Rick Rothstein

obtaining the collumn letter and row number separately
 
Use the Row and Column properties of the range you are working with (with a
twist for the column letter). Assuming R is your range...

RowNumber = R.Row

ColumnNumber = R.Column

ColumnLetter =Split(R.Address(1, 0), "$")(0)

--
Rick (MVP - Excel)


"Sean Farrow" wrote in message
...
Hi:
Isthere a way to obtain the collumn letter (A) for example and hte row
number (2) as separate variables.
Any help apreciated.
Sean.



Sean Farrow

obtaining the collumn letter and row number separately
 
is there a reference to the Split function.
or could someone explain the line:
ColumnLetter =Split(R.Address(1, 0), "$")(0)
cheers
Sean.
Cheers
Sean.
"Rick Rothstein" wrote in message
...
Use the Row and Column properties of the range you are working with (with
a twist for the column letter). Assuming R is your range...

RowNumber = R.Row

ColumnNumber = R.Column

ColumnLetter =Split(R.Address(1, 0), "$")(0)

--
Rick (MVP - Excel)


"Sean Farrow" wrote in message
...
Hi:
Isthere a way to obtain the collumn letter (A) for example and hte row
number (2) as separate variables.
Any help apreciated.
Sean.





Rick Rothstein

obtaining the collumn letter and row number separately
 
Since you posted in the programming newsgroup, I assumed you wanted VBA
code. Split is a VB function that breaks a delimited string of text into an
array of substrings (broken apart at the delimiter). You can see the help
files for Split by placing the caret (text cursor) in or next to the word
"split" and pressing F1. Most people will assign the output of the Split
function to an array and then use that array to pull out one of the
substring. Something like this...

Dim Fields() As String
Fields = Split(R.Address(1, 0), "$")
ColumnLetter = Fields(0)

My code bypassed assigning the output to an array and worked directly with
the array produced by the Split function in memory... that is what the
trailing (0) is for... it says to return the zero element of the array the
Split function directly.

--
Rick (MVP - Excel)


"Sean Farrow" wrote in message
...
is there a reference to the Split function.
or could someone explain the line:
ColumnLetter =Split(R.Address(1, 0), "$")(0)
cheers
Sean.
Cheers
Sean.
"Rick Rothstein" wrote in message
...
Use the Row and Column properties of the range you are working with (with
a twist for the column letter). Assuming R is your range...

RowNumber = R.Row

ColumnNumber = R.Column

ColumnLetter =Split(R.Address(1, 0), "$")(0)

--
Rick (MVP - Excel)


"Sean Farrow" wrote in message
...
Hi:
Isthere a way to obtain the collumn letter (A) for example and hte row
number (2) as separate variables.
Any help apreciated.
Sean.






Sean Farrow

obtaining the collumn letter and row number separately
 
Cheers--it's a long time since I wrote any vb code!
Sean.
"Rick Rothstein" wrote in message
...
Since you posted in the programming newsgroup, I assumed you wanted VBA
code. Split is a VB function that breaks a delimited string of text into
an array of substrings (broken apart at the delimiter). You can see the
help files for Split by placing the caret (text cursor) in or next to the
word "split" and pressing F1. Most people will assign the output of the
Split function to an array and then use that array to pull out one of the
substring. Something like this...

Dim Fields() As String
Fields = Split(R.Address(1, 0), "$")
ColumnLetter = Fields(0)

My code bypassed assigning the output to an array and worked directly with
the array produced by the Split function in memory... that is what the
trailing (0) is for... it says to return the zero element of the array the
Split function directly.

--
Rick (MVP - Excel)


"Sean Farrow" wrote in message
...
is there a reference to the Split function.
or could someone explain the line:
ColumnLetter =Split(R.Address(1, 0), "$")(0)
cheers
Sean.
Cheers
Sean.
"Rick Rothstein" wrote in message
...
Use the Row and Column properties of the range you are working with
(with a twist for the column letter). Assuming R is your range...

RowNumber = R.Row

ColumnNumber = R.Column

ColumnLetter =Split(R.Address(1, 0), "$")(0)

--
Rick (MVP - Excel)


"Sean Farrow" wrote in message
...
Hi:
Isthere a way to obtain the collumn letter (A) for example and hte row
number (2) as separate variables.
Any help apreciated.
Sean.









All times are GMT +1. The time now is 04:40 PM.

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