Public MyLine

Sub NewDailyReports()

' by omypet

Mysheet = ActiveSheet.Name

mypath = ActiveWorkbook.Path

If Mysheet = "2005" Then

MyLine = ActiveCell.Row

FrmLine.TxtLine.Text = MyLine

FrmLine.Show

Mysheet = ActiveSheet.Name

Mydate = Range("A" & MyLine)

MycellA = "A" & MyLine

MycellB = "B" & MyLine

MycellC = "C" & MyLine

Do While Mydate < Date Or Mydate = Date And Mydate <> ""

MyDay = Day(Range("A" & MyLine)) + 1

If Len(MyDay) = 1 Then

MyDay = "0" & MyDay + 1

End If

MyMonth = Month(Range("A" & MyLine))

If Len(MyMonth) = 1 Then

MyMonth = "0" & MyMonth

End If

MyYear = Right(Year(Range("A" & MyLine)), 4)

MyDateFile1 = "myfile-" & MyYear & "-" & MyMonth & "-" & MyDay & ".xls"

If Dir(mypath & "\" & MyDateFile1) = "" Then

If Range(MycellB).Value = "" Then

Range(MycellB).Value = ""

End If

If Range(MycellC).Value = "" Then

Range(MycellC).Value = ""

End If

If Range(MycellD).Value = "" Then

Range(MycellD).Value = ""

End If

Else

FormulaB = "='" & mypath & "\[" & MyDateFile1 & "]Summary'!$K$13"

Range(MycellB).Formula = FormulaB

FormulaC = "='" & mypath & "\[" & MyDateFile1 & "]Summary'!$E$22"

Range(MycellC).Formula = FormulaC

FormulaD = "='" & mypath & "\[" & MyDateFile1 & "]Summary'!$E$23"

Range(MycellD).Formula = FormulaD

FormulaE = "='" & mypath & "\[" & MyDateFile1 & "]Production'!$M$9"

End If

MyLine = MyLine + 1

Mydate = Range("A" & MyLine)

MycellA = "A" & MyLine

MycellB = "B" & MyLine

MycellC = "C" & MyLine

MycellD = "D" & MyLine

Loop

End If

End Sub