Hello,
I have a macro, which basically updates all the country details, respectively, by dynamically creating country folders and country sheets from the original all the country updated excel file. It runs perfectly fine without errors on my desktop , but gives me run time error when used on a network drive.. why is it?? the macro is copied below....
Sub DistributeRowsToNewWBS()
Dim wbNew As Workbook
Dim wsData As Worksheet
Dim wsCrit As Worksheet
Dim wsNew As Worksheet
Dim rngCrit As Range
Dim LastRow As Long
Dim myCountry As String
Dim myNewPath As String
Dim mySourcePath As String
Dim myFinalFolder As String
Dim dt As String
Set wsData = Worksheets("Combined Decision Logs 12_Mar") ' name of worksheet with the data
Set wsCrit = Worksheets.Add
LastRow = wsData.Range("B" & Rows.Count).End(xlUp).Row
' column H has the criteria
wsData.Range("F1:F" & LastRow).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=wsCrit.Range("B1"), Unique:=True
Set rngCrit = wsCrit.Range("B2")
While rngCrit.Value <> ""
Set wsNew = Worksheets.Add
' change E to reflect columns to copy
wsData.Range("B1:U" & LastRow).AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=rngCrit.Offset(-1).Resize(2), CopyToRange:=wsNew.Range("B1"), Unique:=True
wsNew.Name = rngCrit
wsNew.Copy
Set wbNew = ActiveWorkbook
myCountry = rngCrit.Value
mySourcePath = "http://one.akzonobel.intra/bu/113_90/projects/winport/team/Shared%20Documents/UPP/Country%20reviews/"
myFinalFolder = "\Decison And Action Logs\"
myNewPath = mySourcePath & myCountry
On Error Resume Next
MkDir myNewPath
On Error GoTo 0
myNewPath = myNewPath & myFinalFolder
On Error Resume Next
MkDir myNewPath
On Error GoTo 0
'saves new workbook in path of existing workbook
dt = Format(CStr(Now), "dd_mm_yy")
wbNew.SaveAs myNewPath & rngCrit & dt -----------get an error here .
wbNew.Close SaveChanges:=True
Application.DisplayAlerts = False
wsNew.Delete
rngCrit.EntireRow.Delete
Set rngCrit = wsCrit.Range("B2")
Wend
wsCrit.Delete
Application.DisplayAlerts = True
End Sub
Could someone kindly some this problem.. its taking me ages to solve it..
Thanks,
Anchal.
Bookmarks