BelfastHatter
Board Regular
- Joined
- Nov 7, 2008
- Messages
- 60
Hello I have a macro that should loop through the sheets until it reaches the sheet named "HO". However it still tries to run the macro on this sheet.
Please can someone let me know where I have gone wrong.
Here is my code.
Sub Nursery()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "HO" Then
Application.DisplayAlerts = False
ActiveSheet.Copy
Dim src As Variant
src = ActiveWorkbook.LinkSources(xlLinkTypeExcelLinks)
ActiveWorkbook.BreakLink src(1), xlLinkTypeExcelLinks
Dim path As String
Dim filename As String
path = "T:\Nursery Financial Reports" & Range("B1") & "" & Range("C1") & ""
filename = Range("B1") & " - " & Range("Q1")
ActiveWorkbook.SaveAs filename:=path & filename & ".xls", FileFormat:=xlNormal
Application.DisplayAlerts = True
ActiveWorkbook.Close
ActiveSheet.Next.Select
End If
Next ws
End Sub
Thanks
Please can someone let me know where I have gone wrong.
Here is my code.
Sub Nursery()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "HO" Then
Application.DisplayAlerts = False
ActiveSheet.Copy
Dim src As Variant
src = ActiveWorkbook.LinkSources(xlLinkTypeExcelLinks)
ActiveWorkbook.BreakLink src(1), xlLinkTypeExcelLinks
Dim path As String
Dim filename As String
path = "T:\Nursery Financial Reports" & Range("B1") & "" & Range("C1") & ""
filename = Range("B1") & " - " & Range("Q1")
ActiveWorkbook.SaveAs filename:=path & filename & ".xls", FileFormat:=xlNormal
Application.DisplayAlerts = True
ActiveWorkbook.Close
ActiveSheet.Next.Select
End If
Next ws
End Sub
Thanks