[Solved] Derive column letter from formula

Discuss the spreadsheet application
Post Reply
masv
Posts: 1
Joined: Fri Jun 15, 2012 5:30 pm

[Solved] Derive column letter from formula

Post by masv »

I'm trying to 'derive' the Column 'Letter' from a formula.

So, if I know that the Column Number is 5 - how do I 'derive' the Column Letter "E" based on the Column Number?

Can you assist me?
Last edited by MrProgrammer on Mon May 25, 2020 4:36 am, edited 1 time in total.
Reason: Tagged ✓ [Solved]
OpenOffice 3.1 on Windows 7
User avatar
RoryOF
Moderator
Posts: 35054
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Derive column letter from formula

Post by RoryOF »

Add 40H to your column number and convert it to a character. Google for ASCII encoding to see why.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.5 LTS
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Derive column letter from formula

Post by JohnSUN-Pensioner »

Welcome to the forum!
Yes, we can... Try THIS
(Sorry for the brevity of the answer - just now come together teams of France and Ukraine)
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
User avatar
karolus
Volunteer
Posts: 1226
Joined: Sat Jul 02, 2011 9:47 am

Re: Derive column letter from formula

Post by karolus »

Hallo

For what do you "need" the Columnletter ?

If you want to feed =INDIRECT(..) with that, try =OFFSET(...) instead INDIRECT.

Karo
AOO4, Libreoffice 6.1 on Rasbian OS (on ARM)
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 24.8… flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Derive column letter from formula

Post by JohnSUN-Pensioner »

Sometimes the column letter used for the heading: "Option A", "Option B"...
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: Derive column letter from formula

Post by Charlie Young »

RoryOF's solution will only work if it is a single-letter column.

This should get the column "letters" of any cell in which it is entered:

Code: Select all

=LEFT(ADDRESS(ROW();COLUMN();4);SEARCH("[:digit:]";ADDRESS(ROW();COLUMN();4))-1)
Apache OpenOffice 4.1.1
Windows XP
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Derive column letter from formula

Post by JohnSUN-Pensioner »

Yes, my dear friend, you're right! +1
But this record is shorter:

Code: Select all

=SUBSTITUTE(ADDRESS(1;COLUMN();4);"1";"")
I referred to it in his response ... (Now break. Account until 0:0)
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
User avatar
karolus
Volunteer
Posts: 1226
Joined: Sat Jul 02, 2011 9:47 am

Re: Derive column letter from formula

Post by karolus »

Hallo
Charlie Young wrote:RoryOF's solution will only work if it is a single-letter column.

This should get the column "letters" of any cell in which it is entered:

Code: Select all

=LEFT(ADDRESS(ROW();COLUMN();4);SEARCH("[:digit:]";ADDRESS(ROW();COLUMN();4))-1)

Code: Select all

=SUBSTITUTE(ADDRESS(1;COLUMN();4);"1";"")
Karo
AOO4, Libreoffice 6.1 on Rasbian OS (on ARM)
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 24.8… flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: Derive column letter from formula

Post by Charlie Young »

JohnSUN-Pensioner wrote:Yes, my dear friend, you're right! +1
But this record is shorter:

Code: Select all

=SUBSTITUTE(ADDRESS(1;COLUMN();4);"1";"")
I referred to it in his response ... (Now break. Account until 0:0)
Yes, I missed your solution while I was trying mine. :oops:
Apache OpenOffice 4.1.1
Windows XP
User avatar
RoryOF
Moderator
Posts: 35054
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Derive column letter from formula

Post by RoryOF »

Charlie Young wrote:RoryOF's solution will only work if it is a single-letter column.
I was (naturally!) leaving the extended case as an exercise for the OP! [Thinks: does anyone still use EBCDIC?]
Apache OpenOffice 4.1.15 on Xubuntu 22.04.5 LTS
User avatar
JohnSUN-Pensioner
Volunteer
Posts: 876
Joined: Fri Jan 14, 2011 1:21 pm
Location: Kyiv, Ukraine

Re: Derive column letter from formula

Post by JohnSUN-Pensioner »

RoryOF wrote:Thinks: does anyone still use EBCDIC?
I think everyone who was holding a real punched cards can remember what it was :D
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
thomasjk
Volunteer
Posts: 4452
Joined: Tue Dec 25, 2007 4:52 pm
Location: North Carolina

Re: Derive column letter from formula

Post by thomasjk »

I remember EBCIDIC and punched cards quite well. Hmmmmmm, my age is showing :D
Tom K.
Windows 11 23H2
LibreOffice
User avatar
MrProgrammer
Moderator
Posts: 5258
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Derive column letter from formula

Post by MrProgrammer »

RoryOF wrote:Thinks: does anyone still use EBCDIC?
Most of my professional experience (30+ years) was on the EBCDIC platform. There we would add X'F0' to the digit to get the corresponding numeric character. Actually, for technical reasons, it was more common to OR the value with X'F0' than to add. For multiple digits, there was a nice 3-hardware-instruction combination to convert all of them at once: CVD/UNPK/OI.

A few years back, for fun, I wrote some 360/370 assembler programs using the restriction that all of the instructions had to use characters from the subset of printable EBCDIC (upper/lower case, digits, and special characters below). This turns out to be rather challenging, since in a typical program most of the opcodes and data references will be unprintable characters. For example, register 11 is not easily accessible since none of the Bx characters are printable and the handy Branch Conditional and Store Multiple instructions are not available since their opcodes are 47 and 90. I was eventually able to write "Hello World" using this restriction. The machine instructions follow. They are, of course, not meaningful for anyone other than people intimately familiar with the 360/370 instruction set or for the hardware itself which will print "Hello World" when the instructions are executed. The first instruction is 5ED0F040 or ";}0 ", an unsigned add incrementing register 13. The program is "reentrant" in mainframe-speak and would run on any hardware back to the 360 model 30.

Code: Select all

;}0 ¨}0<K } 0&&P } 0f&&\}d¨\}dgT} All bytes are printable chars!AOOl20080808AOOL
Pz/DPz/P--zHDP-PD+//A/zH$N+D/P;N+D-SD/+D//D-z-A/zP*:*:i`jhh`jp0j`0eP/PN;,,rj`0i:
;hj,i:;hjhcj;h,,*/`*ra`l.e$dNz+AAyD+zPN+zDD+zD$D+P/PDPzDD+zPA/+*D:D+zD$-+P/PDP-P
ANAzzAD/zAP+*$$;P-;P$*(C) 2008 BY MrProgrammerAOO-PPPPAOO-AOO-*PPP-%-;+**-PPPNAO
O-AOO-AOO-AOO-AOO-AOO-AOO-PPP-AOO-AOO-AOO-e`;iR`e;`.e;`*e;`*I.;P,DeP`+e;`.rj;%An
e;`*I\;P,CeP/PRHr``icj`ZpfRHHHpFH+HQ(C) 2008 BY MrProgrammerAOO/PPpPAOO/AOO/QPPP
bdbipnicNPPeAOO/AOO/AOO-AOO-AOO/AOO/AOO/PPP%AOO/AOO-AOO/
JohnSUN-Pensioner wrote:I think everyone who was holding a real punched cards can remember what it was :D
I didn't work much with punch cards and unit record equipment, but I still recall the few times when cards got jammed inside a collator and I had to use a card saw to remove the pieces.
Screen shot 2012-06-19 at 13.28.42 .png
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.5, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
Post Reply