I would think the best time to put the dates is right after you copy the
text to sheet1 in the text file, and before you copy that to your workbook.
Here is a snippet from your code with the lines added to put the Date in
column L as far down as there is data in column K.
Rows("1:1").Select
Selection.Insert Shift:=xlDown
Cells.Select
Selection.AutoFilter
Selection.AutoFilter Field:=11, Criteria1:="=STAU"
Sheets.Add
Sheets("klm").Select
Rows("1:6000").Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
ActiveSheet.Paste
Range("L1").Value = Date
Range("L1", Range("K1").End(xlDown)).Offset(0, 1).FillDown
Mike F
Thanks Mike and Ron
Here is the Macro which I should have included first time
Sub klm()
Workbooks.OpenText Filename:="M:\Statdata\klm.txt",
Origin:=xlMSDOS, _
StartRow:=1, DataType:=xlDelimited,
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False,
Comma:=True _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1),
Array(2, 1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7,
1), Array(8, 1), Array(9, 1), _
Array(10, 1)), TrailingMinusNumbers:=True, Local:=True '<-
this decides date interpretation
Selection.Sort Key1:=Range("H1"), Order1:=xlDescending,
Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal
Rows("1:1").Select
Selection.Insert Shift:=xlDown
Cells.Select
Selection.AutoFilter
Selection.AutoFilter Field:=11, Criteria1:="=STAU"
Sheets.Add
Sheets("klm").Select
Rows("1:6000").Select
Selection.Copy
Sheets("Sheet1").Select
Range("A1").Select
ActiveSheet.Paste
Rows("2:6000").Select
Selection.Copy
Workbooks.Open Filename:= _
"G:\J\klm.xls", Origin:=xlWindows
Range("A65536").End(xlUp).Offset(1, 0).Select
ActiveSheet.Paste
Cells.Select
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal
Columns("A:A").Select
Set Rng = ActiveSheet
R = 1
N = 1
With Rng
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
Do While N <= LastRow
If R Mod 500 = 0 Then
Application.StatusBar = "Processing Row: " & Format(R,
"#,##0")
End If
V = .Range("A" & R).Value
If V = vbNullString Then
If Application.WorksheetFunction. _
CountIf(.Columns(1), vbNullString) > 1 Then
.Rows(R).Delete
End If
Else
Next_V = .Range("A" & (R + 1)).Value
If V = Next_V Then
Thisdate = .Range("H" & R).Value
NextDate = .Range("H" & (R + 1)).Value
If Thisdate < NextDate Then
.Rows(R + 1).Delete
Else
.Rows(R).Delete
End If
Else
R = R + 1
End If
End If
N = N + 1
Loop
End With
Cells.Select
Selection.Sort Key1:=Range("H2"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom,
_
DataOption1:=xlSortNormal
ActiveWorkbook.Save
End Sub
Thanks for offering your help
Eddie