Excel Script code to hide unhide rows

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I'm very new to Excel scripts and starting back at the beginning again,
I'm finding it hard to code as I have no examples other than the few Excel has to offer, so I'm hoping someone can help me

In Excel online, I'm looking for a script that when run, if rows 10 to 20 are hidden it unhides them, if they are unhidden they hide.
activesheet is fine or if it helps the sheets name is "Looks"
please could someone help me with this so I can get started.

Thanks

Tony
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Excel Online cannot run VBA scripts. You'd have to open it on Apps. Something like this.
VBA Code:
Sub Hide()
    Dim ws As Worksheet
    Dim rng As Range
    Dim row As Integer
   
    Set ws = ThisWorkbook.Sheets("Looks")
   
    If ws.Rows("10:20").Hidden = True Then
        ws.Rows("10:20").Hidden = False
    Else
        ws.Rows("10:20").Hidden = True
    End If
End Sub
 
Upvote 0
Hi Cubist,
I'm sorry i guess I didn't make that clear, I'm using Excel on line and want code written in the Excel Scripts code not VBA
 
Upvote 0
Maybe this.
Rich (BB code):
function main(workbook: ExcelScript.Workbook) {
    const looksSheet = workbook.getWorksheet("Looks");
    const areRowsHidden = looksSheet.getRange("10:20").getRowHidden();
    looksSheet.getRange("10:20").setRowHidden(!areRowsHidden);
}
 
Upvote 1
Solution
sorry just come back to this after my holiday, this is great thank you for your help Cubist :-)
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,189
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top