Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cell Name

Status
Not open for further replies.

dotnik

Programmer
Nov 14, 2003
24
IT
Good morning,
I'm writing a procedure that elaborate a dbf and export the results to excel's sheet.
As I can know the name of the cells knowing row and column number?
For Example
Row = 001
Col = 001
RowName = "A1"
What is the name of the cell with row 23 and column 004?

I write from South of Italy, excuse me for my english!
Best regards.
Nicola
 
Why you need this?
You can always put:
Code:
oExcel.ActiveSheet.Cells(23, 4).Select


Borislav Borissov
 
Yes,
but if I want select a range of select, (f.e. B2:D21), I must know the cell's name.
Thansk
Nicola
 
Code:
WITH oExcel.ActiveSheet
     .Range(.Cells(2, 2), .Cells(4, 21)).Select
ENDWITH

Borislav Borissov
 
It is unclear what information you have available to construct the cell reference. Borislav's code will work if you are dealing with rows and columns using numbers - for example using a loop counter in a loop to generate values in cells.

To answer your question directly without knowing if the answer will actually help you, the first 26 columns in Excel are labelled "A" through "Z", using the Roman alphabet.
The next 26 columns are labelled "AA" through "AZ".
The third 26 are labelled "BA" through "BZ".
The fourth 26 are labelled "CA" through "CZ".
The fifth 26 are labelled "DA" through "DZ".
The sixth 26 are labelled "EA" through "EZ".
etc.

Hopefully you can see the pattern. The highest column label is "IV".


Mike Krausnick
Dublin, California
 
Code:
CREATE TABLE xlcols (xlnum n(3),xlchr c(2))

FOR i = 1 TO 256
  INSERT INTO xlcols VALUES (i,;
    IIF(i<=26,CHR(64+i),CHR(64+INT((i-1)/26))+;
    IIF(i>26,CHR((64+(i-(INT((i-1)/26)*26)))),"")))
ENDFOR
LOCATE 
BROWSE NOWAIT
 
dotnik,

If you still want to get the A1 type name, try this
Code:
STRTRAN(owx.ActiveSheet.cells(1,1).Address,[$],[])


Hope that helps,

Stewart
PS If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top