Re: [libreoffice-users] Calc: how to auto-increment sheet names in a cell formula?

2023-09-24 Thread Remy Gauthier
Hi,
You could name the location of the data on each sheet with a name
created in a way that makes it easy to figure out the name from the row
number. You can then use the INDIRECT() function to retrieve the
information you want.

For example, on the second sheet, the name of the range could be
Source2. You would retrieve the information like this if you have the
formula on row 2:

=INDIRECT(CONCATENATE("Source",ROW())

This will return a reference to the full range, you can then use the
INDEX() function to retrieve the individual values from Ax to Ex.

I hope this helps.
Rémy.

Le mardi 19 septembre 2023 à 23:06 -0700, Tom Cloyd MS MA a écrit :
> I have trying to solve this problem all evening, with no hint of
> success:
> 
> Let's say I have 11 sheets in a Calc spreadsheet. Sheets 2 to 11
> contain 
> data summarized in cells A1:E1 of each sheet.
> 
> I want to capture these summary data in sheet 1, starting with cell 
> A1:E1. But I then want to copy those cells into the next row and have
> the references point to the next SHEET - sheet 3.
> 
> The general problem is that I have a number of sheets from which I
> want 
> to capture such summary data, but without having to manually edit the
> cell formulas each time to get them to point to the next sheet.
> 
> Incidentally, the sheet names are NOT sheet1, sheet2, etc. So moving
> to 
> the next sheet needs to use some general method of incrementing the 
> sheet reference.
> 
> Is there an artful way to do this?
> 
> Thanks for any ideas offered!
> 
> -- 
> 
> ~
> 
> “Love recognizes no barriers. It jumps hurdles, leaps fences,
> penetrates walls
> to arrive at its destination full of hope.” ~ Maya Angelou
> ~
> 
> Tom Cloyd, MS MA LMHC (WA) | t...@tomcloyd.com
> Psychological trauma & dissociative disorders, treatment, research, &
> advocacy
> Spokane, Washington, U.S.A. | (435) 272-3332
> https://www.gettraumainfo.com/ (professional)
> Facebook: https://www.facebook.com/groups/645665272216298/
> www.tomcloyd.com/ (personal)
> ~
> 
> System76 Galago Pro (galp5) laptop
> Processors: 8 × 11th Gen Intel® Core™ i7-1165G7 @ 2.80GHz
> RAM: 16 GB Dual Channel DDR4 at 3200 MHz
> Storage: 500 GIB SSD
> Operating System: Pop!_OS 22.04 LTS
> Kernel Version: 6.2.6-76060206-generic x86_64
> Gnome ver. 42.5
> Windowing system: X11
> Qt Version: 5.13.3
> [updated 2023-05-09:1420]
> 
> 


-- 
To unsubscribe e-mail to: users+unsubscr...@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy


Re: [libreoffice-users] Calc: how to auto-increment sheet names in a cell formula?

2023-09-20 Thread Michael D. Setzer II
On 19 Sep 2023 at 23:06, Tom Cloyd MS MA wrote:

Date sent:  Tue, 19 Sep 2023 23:06:41 -0700
To: LibreOffice User's Help Forum 

From:   Tom Cloyd MS MA 

Subject:[libreoffice-users] Calc: how to 
auto-increment sheet names in a cell formula?

> I have trying to solve this problem all evening, with no hint of success:
> 
> Let's say I have 11 sheets in a Calc spreadsheet. Sheets 2 to 11 contain 
> data summarized in cells A1:E1 of each sheet.
> 
> I want to capture these summary data in sheet 1, starting with cell 
> A1:E1. But I then want to copy those cells into the next row and have 
> the references point to the next SHEET - sheet 3.
> 
> The general problem is that I have a number of sheets from which I want 
> to capture such summary data, but without having to manually edit the 
> cell formulas each time to get them to point to the next sheet.
> 
> Incidentally, the sheet names are NOT sheet1, sheet2, etc. So moving to 
> the next sheet needs to use some general method of incrementing the 
> sheet reference.
> 
> Is there an artful way to do this?

Not 100% sure I understand exactly what you want, but did a test 
macro that does what I think you want. Isn't complex, but mainly a 
process. The Macro uses Page numbers, so it doesn't care what the 
Sheets names are:

Recorded manual process first. Had macro go to cell A30
Then had it copy a1:e1 on second sheet, and go down.
Then copied the lines.
First couple copied the macro lines manually, and modified 
numbers for each arg one by one. Then got smart, and changed 
numbers in blocks of 10 to make it simplier. Just copied the block 
in geany and then changed page number to go to, and then 
changed numbers in next block. Should be obvious.

Only thing might add is to clear the lines on sheet1 since second or 
later times, it gives pop up message since pasting is overwriting 
data. 

sub multisheet2
rem --
rem define variables
dim document   as object
dim dispatcher as object
rem --
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = 
createUnoService("com.sun.star.frame.DispatchHelper")

rem --
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$A$30"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, 
args1())

rem --
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "Nr"
args2(0).Value = 2

dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, 
args2())

rem --
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$A$1:$E$1"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, 
args3())

rem --
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())

rem --
dim args5(0) as new com.sun.star.beans.PropertyValue
args5(0).Name = "Nr"
args5(0).Value = 1

dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, 
args5())

rem --
dim args6(5) as new com.sun.star.beans.PropertyValue
args6(0).Name = "Flags"
args6(0).Value = "SVDFNT"
args6(1).Name = "FormulaCommand"
args6(1).Value = 0
args6(2).Name = "SkipEmptyCells"
args6(2).Value = false
args6(3).Name = "Transpose"
args6(3).Value = false
args6(4).Name = "AsLink"
args6(4).Value = false
args6(5).Name = "MoveMode"
args6(5).Value = 4

dispatcher.executeDispatch(document, ".uno:InsertContents", "", 0, 
args6())

rem --
dim args7(1) as new com.sun.star.beans.PropertyValue
args7(0).Name = "By"
args7(0).Value = 1
args7(1).Name = "Sel"
args7(1).Value = false

dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, 
args7())

rem --
dim args8(0) as new com.sun.star.beans.PropertyValue
args8(0).Name = "Nr"
args8(0).Value = 3

dispatcher.executeDispatch(document, ".uno:JumpToTable", "", 0, 
args8())

rem --
dim args9(0) as new com.sun.star.beans.PropertyValue
args9(0).Name = "ToPoint"
args9(0).Value = "$A$1:$E$1"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, 
args9())

rem --
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())

rem --
dim args10(0) as new