Sub OpenURL()
Dim x As Integer, wb As Workbook, wb18 As Workbook, rngCopy As Range, wsDnLd As Worksheet
Dim DnLdWkBk, DnLdWkSht, StnWkBk, StnName, StnID, Prov, FMth, FYr, LMth, LYr As String
Dim MostRecent, fname1, fname2, fname3, DtStr, fol As String
Dim UpdateMth, UpdateYr, FMthCal, LMthCal, ObjFile, ObjFileName, fso
Set fso = CreateObject("Scripting.FileSystemObject")
DtStr = Format(Date, "yyyy-mm-dd")
DnLdWkBk = "Aut dwnld(ver3).xls"
DnLdWkSht = "aut dwnlds"
Set wsDnLd = Workbooks(DnLdWkBk).Sheets(DnLdWkSht)
FMth = wsDnLd.Cells(7, "G")
FYr = wsDnLd.Cells(8, "G")
LMth = wsDnLd.Cells(10, "G")
LYr = wsDnLd.Cells(11, "G")
FMthCal = MonthName(FMth, True)
LMthCal = MonthName(LMth, True)
MostRecent = "Update " & FMthCal & FYr & " - " & LMthCal & LYr
For x = 18 To wsDnLd.Cells.SpecialCells(xlCellTypeLastCell).Row
If Len(Trim(Replace(wsDnLd.Cells(x, "F").Value, Chr(160), Chr(32)))) > 0 Then
Set wb = Workbooks.Open(Filename:=wsDnLd.Cells(x, "F").Value)
StnName = wb.Sheets("Sheet1").Cells(1, 2)
StnID = wb.Sheets("Sheet1").Cells(6, 2)
UpdateMth = wb.Sheets("Sheet1").Cells(18, 3)
UpdateYr = wb.Sheets("Sheet1").Cells(18, 2)
Prov = wb.Sheets("Sheet1").Cells(2, 2)
fol = "S:\in.data\" & DtStr & " " & StnName 'Not 'StationName'
fname1 = UpdateYr & "_" & UpdateMth & "_" & StnName & "_" & StnID & ".xls"
If Not fso.FolderExists(fol) Then fso.CreateFolder (fol)
wb.SaveAs Filename:=fol & "\" & fname1, FileFormat:=xlNormal
fol = "S:\Proc\" & Prov & "\" & StnID & " - " & StnName & "\Work"
If Not fso.FolderExists(fol) Then fso.CreateFolder (fol)
fol = fol & "\" & MostRecent '**********
fname2 = UpdateYr & "_" & UpdateMth & "_" & StnName & "_" & StnID & ".xls"
If Not fso.FolderExists(fol) Then fso.CreateFolder (fol)
wb.SaveAs Filename:=fol & "\" & fname2, FileFormat:=xlNormal '**********
fname3 = "01" & MostRecent & "_" & StnName & ".xls"
If x = 18 Then
Set rngCopy = wsDnLd.Range("A17", wsDnLd.Cells.SpecialCells(xlLastCell))
Set wb18 = Workbooks.Add(xlWBATWorksheet) '- only use one worksheet
wb18.Sheets(1).Range(rngCopy.Address).Value = rngCopy.Value
wb18.Sheets(1).Columns("A:A").EntireColumn.AutoFit
wb18.SaveAs Filename:=fol & "\" & fname3, FileFormat:=xlNormal '**********
Else
'Not sure what you want to do here, but this can be revised as well...
Set rngCopy = wsDnLd.Range("A18", ActiveCell.SpecialCells(xlLastCell))
Workbooks(fname3).Sheets("Sheet1").Paste Range("A1").Offset(Cells.SpecialCells(xlCellTypeLastCell).Row, 0)
ActiveWorkbook.Save
End If
End If
Next x
End Sub