VBA code not working


Getting the error: “Invoke VBA: Cannot run the macro ‘CheckHiddenRowsColumns’. The macro may not be available in this workbook or all macros may be disabled.”

The code that I am implementing:

Function CheckHiddenRowsColumns(sheetName As String) As Boolean
    Dim cell As Object
    Dim hiddenRows As Boolean
    Dim hiddenColumns As Boolean
    ' Activate the specified sheet
    Sheets(sheetName).Activate
 
    ' Check for hidden rows
    For Each cell In ActiveSheet.UsedRange.Rows
        If cell.EntireRow.Hidden Then
            hiddenRows = True
            Exit For
        End If
    Next cell
 
    ' Check for hidden columns
    For Each cell In ActiveSheet.UsedRange.Columns
        If cell.EntireColumn.Hidden Then
            hiddenColumns = True
            Exit For
        End If
    Next cell
 
    ' Set the result based on hidden rows or columns
    CheckHiddenRowsColumns = hiddenRows Or hiddenColumns
End Function

Any idea on why this is happening? Thanks in advance

@Biswas_Ishan

  1. First check the excel settings…Excel-> Options-> Advanced->Trust center settings-> Macros-> Enable macros
  2. Try to delete the file and recreate the file again and check sometimes the file might become inaccessible

cheers

Hi @Biswas_Ishan

Check the below thread

or
Try to update the packages in the manage package by making Runtime rule as lowest as applicable.
image

Hope it helps!!

Done all those, still problem persists

This is to do with how the macro is saved within Excel and not being global. Plus make sure they are Truseted in the Trust centre as above

Need to be saved as modules within
image

How do i reach this place?

tried this, didnt work

@Biswas_Ishan

While resaving try to create new file in someother location and then save with different name and integrate and check

cheers

Ohh wow, it worked, what a weird solution :sweat_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.