[Solved] Can't use column label 'Quantity' on other sheets

Discuss the spreadsheet application
Locked
swdistro
Posts: 23
Joined: Thu Sep 30, 2021 5:38 am

[Solved] Can't use column label 'Quantity' on other sheets

Post by swdistro »

I need to use column names as the reference in formulas on Sheet2 since the column letters may change depending on how certain export data comes out.

Using the names in a formula on Sheet1 (the sheet the columns exist on) works fine (i.e. =SUM('Quantity') returns the sum of all the numbers in the Quantity column), but calling to the column name on Sheet2 returns Err:508 no matter which way I type it ( =SUM(Sheet1.Quantity), =SUM(Sheet1.'Quantity'), etc). I'm not sure if I'm just typing something wrong or what.

Any help would be appreciated. Thanks.

 Edit: Changed subject, was Using Column Name instead of letter not working 
Make your post understandable by others 
-- MrProgrammer, forum moderator 
Last edited by swdistro on Fri Aug 30, 2024 10:12 pm, edited 1 time in total.
OpenOffice 4.1.14 on Windows 11 Pro 64-bit
User avatar
robleyd
Moderator
Posts: 5504
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Using Column Name instead of letter not working

Post by robleyd »

=SUM(Quantity) is what you need, from any sheet in the document. The range name definition includes the sheet on which it is contained.
Slackware 15 (current) 64 bit
Apache OpenOffice 4.1.16
LibreOffice 26.2.3.2; SlackBuild for 26.2.3 by Eric Hameleers
---------------
I hate this damn computer, I wish that I could sell it.
It won't do what I want it to, Only what I tell it.
swdistro
Posts: 23
Joined: Thu Sep 30, 2021 5:38 am

Re: Using Column Name instead of letter not working

Post by swdistro »

robleyd wrote: Thu Aug 29, 2024 5:11 am =SUM(Quantity) is what you need, from any sheet in the document. The range name definition includes the sheet on which it is contained.
This only works on Sheet1 (the sheet the named column is in).
OpenOffice 4.1.14 on Windows 11 Pro 64-bit
User avatar
robleyd
Moderator
Posts: 5504
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Using Column Name instead of letter not working

Post by robleyd »

Perhaps you could elaborate on how you create column names? My answer presumed a named range.
Slackware 15 (current) 64 bit
Apache OpenOffice 4.1.16
LibreOffice 26.2.3.2; SlackBuild for 26.2.3 by Eric Hameleers
---------------
I hate this damn computer, I wish that I could sell it.
It won't do what I want it to, Only what I tell it.
User avatar
Lupp
Volunteer
Posts: 3756
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Using Column Name instead of letter not working

Post by Lupp »

swdistro wrote: Thu Aug 29, 2024 4:33 am I need to use column names as the reference in formulas on Sheet2 since the column letters may change depending on how certain export data comes out.
Are you using the option 'Automatically find column and row labels' ?
Are what you refer to as "column names" actually labels inserted into the first row?
This is a dirty way to get partially the functionality of named ranges. It never is usable from a different sheet. Moreover it is only implemented to the full(?) extent in LibO.

My suggetion:
Disable the mentioned option.
Always use explicitly defined named ranges. Using LibO you can even choose the scope of the range definition.
(@robleyd obviously assumed you do it the explicit way.)
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
swdistro
Posts: 23
Joined: Thu Sep 30, 2021 5:38 am

Re: Using Column Name instead of letter not working

Post by swdistro »

swdistro wrote: Thu Aug 29, 2024 4:33 am t never is usable from a different sheet.
Ah, okay. So what are my options then if I have to call cells from another sheet where the specific column positions won't be static, but the column headers will be?

i.e. "Title" will always be present as a column header, but in one export it may belong to C1, another export it may be D1 or K1, etc.
OpenOffice 4.1.14 on Windows 11 Pro 64-bit
User avatar
MrProgrammer
Moderator
Posts: 5430
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Using Column Name instead of letter not working

Post by MrProgrammer »

swdistro wrote: Thu Aug 29, 2024 4:33 am Using the names in a formula on Sheet1 (the sheet the columns exist on) works fine (i.e. =SUM('Quantity') returns the sum of all the numbers in the Quantity column), but calling to the column name on Sheet2 returns Err:508 no matter which way I type it
Automatically find column and row labels is a broken idea from Excel. I've never seen any documentation which shows that column labels from one sheet can be used on another sheet. I never use that feature.

swdistro wrote: Thu Aug 29, 2024 3:20 pm So what are my options then if I have to call cells from another sheet where the specific column positions won't be static, but the column headers will be?
Defined names are global to the spreadsheet, so ensure that the headers in row one are unique. Select the range (headers and data) on Sheet1 and use Insert → Names → Create → Top row → OK. Examine the names you created using Insert → Names → Define. You can now use those defined names on Sheet2. Read about the feature in Help → Index or in User Guides (PDF) or searching for topics about it in the Calc Forum.

If you need any additional assistance attach a spreadsheet demonstrating the situation (remove confidential information then use Post Reply, not Quick Reply, and don't attach a picture instead of the spreadsheet itself). I will not help further unless you attach your spreadsheet.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the Subject field. Select the green checkmark icon at the same time.

[Tutorial] Ten concepts that every Calc user should know
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
Lupp
Volunteer
Posts: 3756
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Using Column Name instead of letter not working

Post by Lupp »

swdistro wrote: Ah, okay. So what are my options then if I have to call cells from another sheet where the specific column positions won't be static, but the column headers will be?
References used for the definition of named ranges or named formulas are automatically adapted in the same way as references in cell formulas are.
Check the attached example of a spreadsheet document:
aoo111846_NamedRangesAdaptingReferences.ods
(55.13 KiB) Downloaded 61 times
Last edited by robleyd on Sat Aug 31, 2024 12:46 am, edited 1 time in total.
Reason: Fix quote tags
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
keme
Volunteer
Posts: 3791
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Using Column Name instead of letter not working

Post by keme »

An approach which works "off sheet" and does not require that you define ranges:
Use MATCH() to locate the position of the desired column.
Use OFFSET() to specify a range at that column.
Mockup in attached file.
 Edit: Note that INDEX() returns the item number, counting from 1, while OFFSET() uses the input as a displacement of the original position so "keep original" is the same as zero displacement. This is the reason for the "minus one" in the formula.
It is not uncommon to encounter this kind of 1-base vs zero-base situation with numbering/counting in the digital realm. 
Attachments
PickAColumn.ods
(10.44 KiB) Downloaded 47 times
Last edited by keme on Sun Sep 01, 2024 2:55 pm, edited 1 time in total.
swdistro
Posts: 23
Joined: Thu Sep 30, 2021 5:38 am

Re: Using Column Name instead of letter not working

Post by swdistro »

keme wrote: Fri Aug 30, 2024 3:13 pm An approach which works "off sheet" and does not require that you define ranges:
Use MATCH() to locate the position of the desired column.
Use OFFSET() to specify a range at that column.
Mockup in attached file.
Thank you kindly!
OpenOffice 4.1.14 on Windows 11 Pro 64-bit
Locked