HI,
Not able to hide Worksheets (2nd Time) in following code. Although with first occurrence i.e. Sourcewb worksheets get hide. But with SourcewbA code all the worksheet remains unhide. I tried to even close first and then open second file.
Dim Sourcewb As Worksheet
Dim SourcewbA As Worksheet
Workbooks.Open Filename:= "NTRv1" & ".xlsm"
' Hiding Worksheet of First Workbook
For Each Sourcewb In ThisWorkbook.Worksheets
If Sourcewb.Name <> ThisWorkbook.ActiveSheet.Name Then
Sourcewb.Visible = False
End If
Next Sourcewb
Workbooks("NTRv1" & ".xlsm").Save
Workbooks("NTRv1" & ".xlsm").Close
Workbooks.Open Filename:= "NTRv2" & ".xlsm"
Workbooks("NTRv2").Activate
' Hiding Worksheet of Second Workbook
For Each SourcewbA In ThisWorkbook.Worksheets
If SourcewbA.Name <> ThisWorkbook.ActiveSheet.Name Then
SourcewbA.Visible = False
End If
Next SourcewbA
Not able to hide Worksheets (2nd Time) in following code. Although with first occurrence i.e. Sourcewb worksheets get hide. But with SourcewbA code all the worksheet remains unhide. I tried to even close first and then open second file.
Dim Sourcewb As Worksheet
Dim SourcewbA As Worksheet
Workbooks.Open Filename:= "NTRv1" & ".xlsm"
' Hiding Worksheet of First Workbook
For Each Sourcewb In ThisWorkbook.Worksheets
If Sourcewb.Name <> ThisWorkbook.ActiveSheet.Name Then
Sourcewb.Visible = False
End If
Next Sourcewb
Workbooks("NTRv1" & ".xlsm").Save
Workbooks("NTRv1" & ".xlsm").Close
Workbooks.Open Filename:= "NTRv2" & ".xlsm"
Workbooks("NTRv2").Activate
' Hiding Worksheet of Second Workbook
For Each SourcewbA In ThisWorkbook.Worksheets
If SourcewbA.Name <> ThisWorkbook.ActiveSheet.Name Then
SourcewbA.Visible = False
End If
Next SourcewbA