Hi, I have a workbook that has a lot of hidden sheets. I have a macro that copies all the data off of a hidden sheet onto the main worksheet and uses a "for each" function to hide the rows and columns on the main worksheet based on which rows and columns were hidden on the sheet the data was being copied from. My issue is that the more sheets there are in the worksheet, the longer this task takes. It's taking up to 30 seconds now.
Private Sub RecallBtn_Click() Dim rownum As Long Dim colnum As Long Dim Slctd As String Dim Wstrgt As Worksheet Dim wsdtbase As Worksheet Dim Trgtrnge As Range Dim Dtbasernge As Range Set Dtbasernge = Sheets(TMPNames.Value).Range("a1:em200") Set Trgtrnge = ActiveSheet.Range("a1:em200") rownum = 1 colnum = 1 Application.ScreenUpdating = False Application.EnableEvents = False Trgtrnge.Formula = Dtbasernge.Formula ActiveSheet.Range("r6").Value = TMPNames.Value For Each Column In Sheets(TMPNames.Value).UsedRange.Columns If Sheets(TMPNames.Value).Columns(colnum).Hidden = True Then ActiveSheet.Columns(colnum).Hidden = True Else ActiveSheet.Columns(colnum).Hidden = False End If colnum = colnum + 1 Next Column For Each Row In Sheets(TMPNames.Value).UsedRange.Rows If Sheets(TMPNames.Value).Rows(rownum).Hidden = True Then ActiveSheet.Rows(rownum).Hidden = True Else ActiveSheet.Rows(rownum).Hidden = False End If rownum = rownum + 1 Next Row Call ProtectSheets Application.EnableEvents = True Application.ScreenUpdating = True End Sub