Hello,
I have a source file,which has list of all the country reviews about 20 countries.
They update this file on regular basis. I need to create country files based on the changes and maintain those worksheets.
The source file is in UPP/TRACKING folder.
The destination files should be in for example.. for country italy it should be in path..UPP/COUNTRYREVIEWS/ITALY/DECISION AND ACTION LOGS/
for country greece it should be in UPP/COUNTRYREVIEWS/Greece/DECISION AND ACTION LOGS/
I have a macro which I have written, which filters the data based on country and creates separate worksheets in the same path as in source file..
But I need to create the worksheets under different path.. the macro should create folders based on the country or if folders present leave it and copy then under the path specified above..
This is my macro...
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
Set wsData = Worksheets("overall_reviews1") ' 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("E1:E" & 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:R" & LastRow).AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=rngCrit.Offset(-1).Resize(2), CopyToRange:=wsNew.Range("B1"), Unique:=True
wsNew.Name = rngCrit
wsNew.Copy
Set wbNew = ActiveWorkbook
' saves new workbook in path of existing workbook
wbNew.SaveAs ThisWorkbook.Path & "\" & rngCrit
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
Can anybody solve this problem??
Bookmarks