I'm having trouble finding a converter from a javascript to VBA macro. Can anyone tell me how to accomplish this function as a macro? It hides any row from 4-94 that has a null value in its column A, then continues doing this through the first 12 tabs/worksheets. The macro below works if I run it for each worksheet individually, but not after I have to lock the affected section.
function StepThroughTabs(){
var ss = SpreadsheetApp.getActiveSpreadsheet();//Get the spreadsheet name
var startrow = 4;//establishing the initial header row
var maxrows = 94;//Establishing the final row
for (var x = 0; x < 12; x++) { //Step through the first 12 tabs
var y = ss.getSheets()[x]; //Which tab are you on?
y.showRows(1,maxrows) //grab an array of rows
var vals = y.getRange(1,1,maxrows,1).getValues(); // The second number is the column I want to evaluate, in this case it is column A as a 1
for (var i = startrow; i < maxrows; i++) if (vals[i] == "") y.hideRows(i+1); // Hide the row based on the value found
}
}
I've tried the following code that requires manual selection of the sheets that I want to run but it keeps getting hung up at Set rng = Range("A5:A93") when I save after the workbook is locked. Unfortunately, locking the workbook cannot be avoided.
Sub HideLoop()
Application.ScreenUpdating = False
'Create variable to hold worksheets
Dim ws As Worksheet
'Loop through each selected worksheet
For Each ws In ActiveWindow.SelectedSheets
'Perform action. E.g. hide selected worksheets
Dim c As Range, rng As Range
Set rng = Range("A5:A93")
rng.EntireRow.Hidden = False
For Each c In rng
If c.Value = vbNullString Then c.EntireRow.Hidden = True
Next c
Next ws
Application.ScreenUpdating = True
End Sub
Thank you for any assistance!