obtaining the collumn letter and row number separately

S

Sean Farrow

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

Rick Rothstein

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)
 
S

Sean Farrow

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.
 
R

Rick Rothstein

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top