[Solved] Hide row based on cell value - Issues with macro?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Bdelude89
Posts: 4
Joined: Tue Mar 27, 2018 1:39 am

[Solved] Hide row based on cell value - Issues with macro?

Post by Bdelude89 »

Sub FTest()
theSheet=thisComponent.getSheets.getByName( "Production" )
CellDest = theSheet.getCellByPosition(4,8)
If CellDest.string = "1" then CellDest.Rows.IsVisible=false
end if
end sub
This is my macro that is not working. I have a formula in D8 that detects the length of of another cell in the spreadsheet. It displays "1" if the cell length is zero and nothing if the cell length is greater than zero. If the formula in D8 produces a "1" I want to hide the D row. For some reason this is not working. Could someone with much greater knowledge please help me troubleshoot?
Last edited by Bdelude89 on Wed Mar 28, 2018 2:40 pm, edited 1 time in total.
Openoffice 3 on Windows 10
FJCC
Moderator
Posts: 9274
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Hide row based on cell value - issues with macro?

Post by FJCC »

This line is returning cell E9

Code: Select all

CellDest = theSheet.getCellByPosition(4,8)
because rows and columns are indexed from 0: A = 0, B = 1, C = 2, D = 3. Similarly, and confusingly, row 1 has an index of 0.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Bdelude89
Posts: 4
Joined: Tue Mar 27, 2018 1:39 am

Re: Hide row based on cell value - issues with macro? [SOLVE

Post by Bdelude89 »

Thank you, good looking out!
Openoffice 3 on Windows 10
Post Reply