Forum Discussion
Question related to add headers and hide sheet
Thank you for reply.
But sir when i hide the sheet (WEST SHEET) so it is showing all sheet data.
Like -
So what should i write?
Here I am attach file which i have hide WEST sheet.
If you want to exclude hidden sheets:
Public Sub FinalReportLoop()
Dim i As Integer
Dim ws As Worksheet
Dim wsR As Worksheet
Dim rng As Range
Application.ScreenUpdating = False
Set wsR = Worksheets("Yearly Report")
wsR.Cells.Clear
For i = 1 To Worksheets.Count - 1
Set ws = Worksheets(i)
If ws.Visible = xlSheetVisible Then
AddHeaders ws
FormatData ws
AutoSum ws
If i = 1 Then
Set rng = wsR.Range("A1")
Else
Set rng = wsR.Range("A" & wsR.Rows.Count).End(xlUp).Offset(3)
End If
ws.UsedRange.Copy Destination:=rng
End If
Next i
wsR.Columns("A:F").EntireColumn.AutoFit
Application.ScreenUpdating = True
End Sub
The other procedures remain the same.
- ExcelMar 17, 2021Iron Contributor
Thank you for the Reply😊
I have another doubt that - what if YEARLY REPORT sheet in middle.
Like -
After run this code, it give wrong outcome 2 times EAST and WEST sheet then come NORTH sheet.
Here is a attach file you can see that in YEARLY REPORT sheet.
So what will i add?
- HansVogelaarMar 17, 2021MVP
Public Sub FinalReportLoop() Dim ws As Worksheet Dim wsR As Worksheet Dim rng As Range Dim f As Boolean Application.ScreenUpdating = False Set wsR = Worksheets("Yearly Report") wsR.Cells.Clear For Each ws In Worksheets If ws.Visible = xlSheetVisible And ws.Name <> wsR.Name Then AddHeaders ws FormatData ws AutoSum ws If f Then Set rng = wsR.Range("A" & wsR.Rows.Count).End(xlUp).Offset(3) Else Set rng = wsR.Range("A1") f = True End If ws.UsedRange.Copy Destination:=rng End If Next ws wsR.Columns("A:F").EntireColumn.AutoFit Application.ScreenUpdating = True End Sub- ExcelMar 18, 2021Iron Contributor
Sir how can we do total for JAN, FEB and MAR for all sheet then after run, it should come in YEARLY REPORT sheet.
Like -And After run this code, it should be update in YEARLY REPORT. So what code will i write?
Please help...???
Here is a attach file.