
Originally Posted by
RHCPgergo
Is it possible that one of the worksheets has a different name? Or all of these are correct?
"WON", "NROL", "Hospitals West Midlands", "Hospitals Banbury", "SIGBOX-ECR-CONTL", "VMF", "POIC"
I'm pretty sure theyre all correct, the thing thats funny is that several macro's get called and if I run it from the second macro it runs just fine ! Just not running it as one on the whole :-/
Will post more of coding up !:-)
This is the end of the first main macro -
Next outlead
'create new workbook
shcnt = 0
ReDim aShtLst(1 To 1)
For Each ws In ActiveWorkbook.Worksheets
WSNAME = ws.Name
If Left(WSNAME, 5) = SHTPREFIX Then
ReDim Preserve aShtLst(1 To shcnt + 1)
shcnt = shcnt + 1
aShtLst(shcnt) = WSNAME
End If
Next ws
Sheets(aShtLst).Move
Else ' User chose No.
Application.ScreenUpdating = True
Exit Sub
End If
Call WorkSheetsShow
End Sub
Which leads to
Sub WorkSheetsShow()
Dim sh As Worksheet
For Each sh In Worksheets
sh.Visible = xlSheetVisible
Next
Call backit2
End Sub
Sub backit2()
Dim ThisFile As String, x As Long, ww As Window
ThisFile = ActiveWindow.Caption
For Each ww In Windows
If ww.Visible = True And ww.Caption <> ThisFile Then
Workbooks(ThisFile).Sheets(Array("WON", "NROL", "Hospitals West Midlands", "Hospitals Banbury", _
"SIGBOX-ECR-CONTL", "VMF", "POIC")).Copy after:=Workbooks(ww.Caption).Sheets(Workbooks(ww.Caption).Sheets.Count)
Windows(ThisFile).Activate
ActiveWindow.SelectedSheets.Visible = False
End If
Next ww
Call Sheetstohide
End Sub
Which leads to
Sub Sheetstohide()
'
' Shtstohide Macro
' Macro recorded 12/02/2013 by James Riley
'
'
Worksheets("CSV01").Visible = False
Worksheets("CSV03").Visible = False
Worksheets("ITEM").Visible = False
Worksheets("ContentSheet").Visible = False
Worksheets("Item").Visible = False
Worksheets("WON").Visible = False
Worksheets("NROL").Visible = False
Worksheets("Hospitals west Midlands").Visible = False
Worksheets("Hospitals Banbury").Visible = False
Worksheets("SIGBOX-ECR-CONTL").Visible = False
Worksheets("VMF").Visible = False
Worksheets("POIC").Visible = False
End Sub
Have just checked WS names and yes theyre all correct shouldnt have really as it started as a recorded macro lol :-)
Bookmarks