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

Creating a macro - Writing a Script - Using the API

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

Postby Bdelude89 » Tue Mar 27, 2018 1:43 am

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
Bdelude89
 
Posts: 4
Joined: Tue Mar 27, 2018 1:39 am

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

Postby FJCC » Tue Mar 27, 2018 4:26 am

This line is returning cell E9
Code: Select all   Expand viewCollapse view
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.
AOO 3.4 or 4.1 on MS Windows XP ( before 2013-08-03) or Windows 7
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 6758
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

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

Postby Bdelude89 » Wed Mar 28, 2018 2:41 pm

Thank you, good looking out!
Openoffice 3 on Windows 10
Bdelude89
 
Posts: 4
Joined: Tue Mar 27, 2018 1:39 am


Return to Macros and UNO API

Who is online

Users browsing this forum: Exabot [Bot], JohnSUN-Pensioner, robleyd and 9 guests