How to Modify VBA Code to List Hidden Rows and Columns in Excel
Question details
The user needs a VBA script that can automatically find hidden rows and columns in a spreadsheet and list their details on a newly created worksheet named 'Hidden Rows'.

- Product
- Spreadsheet
- Device & OS
- not provided
- Scenario
- Automating the discovery and reporting of hidden data ranges within a complex workbook to ensure no hidden information is overlooked.
- Observed behavior
- The user requires the specific coding steps and logic to create the worksheet and output the hidden row/column report programmatically.
Ensure that the Developer tab is enabled in your spreadsheet application and save a backup copy of your workbook, as actions performed by VBA macros cannot be undone using the standard Undo feature.
Create a Custom VBA Macro to Detect Hidden Elements
Write a VBA script that iterates through the used range of your active sheet, identifies hidden elements, and writes their addresses to a newly created report sheet.
Since standard spreadsheet functions cannot dynamically generate lists of hidden rows and columns, a custom Visual Basic for Applications (VBA) macro is the most effective approach. The code will need to scan the properties of your rows and columns and output the findings.
Press the 'ALT + F11' shortcut keys on your keyboard to open the Visual Basic for Applications (VBA) editor.
In the top menu, click 'Insert' and select 'Module'. This will create a blank canvas where you can paste or write your custom script.
In the module, define a Sub procedure. Use the command 'Worksheets.Add.Name = "Hidden Rows"' to create the target sheet. Then, use a 'For' loop on the original sheet's UsedRange. Write 'If Rows(i).Hidden = True Then' to capture hidden rows, and similarly for columns. Program the script to print the captured row or column indexes onto the 'Hidden Rows' sheet.
Close the VBA editor. Navigate to the Developer tab, click on 'Macros', select the macro you just created, and click 'Run'. The new worksheet will automatically generate with the report.

Run VBA Macros Seamlessly in WPS Spreadsheet
WPS Office provides robust and professional support for VBA macros. You can easily write, edit, and execute custom scripts to detect hidden rows and automate your spreadsheet tasks without paying for expensive software.
- 1. Open WPS Spreadsheet: Launch your workbook inside WPS Office.
- 2. Access Developer Tools: Navigate to the 'Developer' tab on the main ribbon and click on 'VB Editor'.
- 3. Execute Your Script: Insert a module, paste your hidden-row detection code, and run the macro directly to generate your report.

Frequently Asked Questions
Why is my VBA macro not running or disabled?
Macro execution is often disabled by default for security reasons. To fix this, go to the Developer tab, click on 'Macro Security', and select 'Enable all macros' (use this setting cautiously and only with trusted documents).
Can I check multiple worksheets for hidden rows at the same time?
Yes. You can modify your VBA code to include an outer loop such as 'For Each ws In ActiveWorkbook.Worksheets'. This allows the script to evaluate every tab in the workbook and compile a comprehensive list of all hidden ranges.
Will the 'Hidden Rows' worksheet update automatically if I hide new rows later?
No, standard VBA macros do not run continuously. If you hide or unhide rows after generating the report, you will need to delete the old 'Hidden Rows' sheet and run the macro again to get an updated list.




