[Solved] Dynamically change Chart Data Ranges

Discuss the spreadsheet application
FKlusmann
Posts: 43
Joined: Fri Jan 20, 2017 3:22 am

Re: [Solved] Dynamically change Chart Data Ranges

Post by FKlusmann »

MrProgrammer wrote:Hi, and welcome to the forum.
Thank you, sir.
FKlusmann wrote:… a [chart] of more than the last 10 test becomes meaningless. How can the X-axis be adjusted?
Though the topic is marked Solved, there seem to be additional questions. Perhaps the attached method will be of interest. It does not use evil macros.[/quote]
Very interesting, sir!
As a test, I deleted A33, and see the dreaded dip in the graft. Replacing " IF(ISBLANK(A" with " IF(ISBLANK(B" >>> it is column "B" which may hold non-continuous data <<< caused the counter to restart. It restarted in rows 31, and 19. Therefore 19 points are plotted, going back to 10/11/13 on the X-axis.
Now, if I can figure out how to automate the filter (Data, Autofilter, "HCT", Not_Empty..) and copy the visible data I would be happy. Yes, I have done this with an (evil) macro in Excel 2002.

Thank you for showing me how to create a bottom-up index!
Last edited by FKlusmann on Fri Feb 03, 2017 10:14 pm, edited 1 time in total.
Thank you ALL! (Win 10 - LibreOffice Version: 7.0.3.1 (x64))
Saving the Planet! Only recycled electrons were used in this post!
User avatar
Villeroy
Volunteer
Posts: 31345
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Solved] Dynamically change Chart Data Ranges

Post by Villeroy »

Quick and dirty copy-filter-to-other-sheet macro?

Code: Select all

REM  *****  BASIC  *****
Const cDBRange = "Data" 'name of database range
Const cFieldIndex = 2 'filter 3rd column of the db range
Const cTargetSheet = 0 'copy result to first sheet

Sub CopyFilter()
dbr = ThisComponent.DatabaseRanges.getByName(cDBRange)

aTarget = createUnoStruct("com.sun.star.table.CellAddress")
aTarget.Sheet = cTargetSheet

fld = createUnoStruct("com.sun.star.sheet.TableFilterField")
fld.Operator = com.sun.star.sheet.FilterOperator.EMPTY
fld.Field = cFieldIndex

fd = dbr.getFilterDescriptor()
fd.FilterFields = Array(fld)
fd.CopyOutputData = True
fd.OutputPosition = aTarget

rg = dbr.getReferredCells()
rg.filter(fd)
End Sub
Adjust the 3 constants.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
MrProgrammer
Moderator
Posts: 5287
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: [Solved] Dynamically change Chart Data Ranges

Post by MrProgrammer »

FKlusmann wrote:Now, if I can figure out how to automate the filter (Data, Autofilter, "HCT", Not_Empty..)
Simple formulas; no evil macros.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
Attachments
201702031337.ods
(27.53 KiB) Downloaded 443 times
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.6, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
FKlusmann
Posts: 43
Joined: Fri Jan 20, 2017 3:22 am

Re: [Solved] Dynamically change Chart Data Ranges

Post by FKlusmann »

Villeroy wrote:Quick and dirty copy-filter-to-other-sheet macro?
Thank you, Villeroy!
This finds the correct values. I have not found the syntax assign the output to a cell range (searching both OpenOffice and LibreOffice). Please point me to a URL which teaches the syntax.

Also, my Excel macro in Libreoffice Calc dies at "Selection.Copy" with Runtime error '1' - Type: com.sun.star.uno.RuntimeException Message: That command cannot be used on multiple selections
Thank you ALL! (Win 10 - LibreOffice Version: 7.0.3.1 (x64))
Saving the Planet! Only recycled electrons were used in this post!
FKlusmann
Posts: 43
Joined: Fri Jan 20, 2017 3:22 am

Re: [Solved] Dynamically change Chart Data Ranges

Post by FKlusmann »

MrProgrammer wrote:
FKlusmann wrote:Now, if I can figure out how to automate the filter (Data, Autofilter, "HCT", Not_Empty..)
Simple formulas; no evil macros.
Whoa!, I never considered using Median for anything like this!
First, Find out which cells have values and count with ISNUMBER. That is nice.
(There are 15 over a span of in 21 rows in my modified sheet.)
Second, Use IF to identify a change in sequence provided by the first test.
Third, Use Median to mark the wanted rows "True" (and change the number desired here too!)
Then Copy the desired values based on Median's "True or False"
And Plot the graft!
MrProgrammer, You definitely thought outside of my box.
Thank you!!!!!!!!!
Simple formulas
Yes, used in unique ways by an outstanding helper, MrProgrammer.
Thank you ALL! (Win 10 - LibreOffice Version: 7.0.3.1 (x64))
Saving the Planet! Only recycled electrons were used in this post!
Post Reply