sivaprasad21
New Member
- Joined
- Apr 27, 2011
- Messages
- 2
I have log file in text in a folder.I am running an Macro in an EXCEL,this fetches log and picks up few entries, during that, encountered an error
run-time error 1004: Application-defined or object-defined error.
log file has lots of rows.
Can you please suggest & guide.
the code in RED is highlighted.
piece of code is as :
Sub pr_1()
'
' Macro6 Macro
'
'
ActiveCell.Offset(0, 2).Range("A1").Select
ChDir ActiveCell 'Change the ChDir path to locate the folder containing log files
ActiveCell.Offset(0, -1).Range("A1").Select
Workbooks.OpenText Filename:=ActiveCell, _
Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=True, 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), Array(11, 1)), TrailingMinusNumbers:=True
ActiveCell.Columns("A:A").EntireColumn.Select
Selection.Delete Shift:=xlToLeft
ActiveCell.Offset(0, 10).Range("A1").Select
ActiveCell.FormulaR1C1Local = "=LEFT(R[3]C[-1],4)"
LASTROW = GetLastRowWithData ' Getting the Row number
temp1 = LASTROW
ActiveCell.Select
Selection.Copy
ActiveCell.Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=LEFT(RC[-1],4)"
ActiveCell.Select
Selection.Copy
ActiveCell.Range("A1:A" & temp1).Select
ActiveSheet.Paste
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Range("A1:K" & temp1).Select
ActiveCell.Offset(0, 11).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1Local = _
"=IF(R[0]C[-1]=""laun"",""laun"", IF(R[0]C[-6]=""averages:"",""averages:"",""""))"
ActiveCell.Select
Selection.Copy
ActiveCell.Range("A1:A" & temp1).Select
ActiveSheet.Paste
ActiveCell.Offset(0, -11).Range("A1:L" & temp1).Select
Application.CutCopyMode = False
ActiveCell.Activate
Selection.AutoFilter
ActiveSheet.Range("$A$1:$L$2" & temp1).AutoFilter Field:=12, Criteria1:=Array( _
"=laun", "averages:"), Operator:=xlFilterValues
run-time error 1004: Application-defined or object-defined error.
log file has lots of rows.
Can you please suggest & guide.
the code in RED is highlighted.
piece of code is as :
Sub pr_1()
'
' Macro6 Macro
'
'
ActiveCell.Offset(0, 2).Range("A1").Select
ChDir ActiveCell 'Change the ChDir path to locate the folder containing log files
ActiveCell.Offset(0, -1).Range("A1").Select
Workbooks.OpenText Filename:=ActiveCell, _
Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, _
Comma:=False, Space:=True, 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), Array(11, 1)), TrailingMinusNumbers:=True
ActiveCell.Columns("A:A").EntireColumn.Select
Selection.Delete Shift:=xlToLeft
ActiveCell.Offset(0, 10).Range("A1").Select
ActiveCell.FormulaR1C1Local = "=LEFT(R[3]C[-1],4)"
LASTROW = GetLastRowWithData ' Getting the Row number
temp1 = LASTROW
ActiveCell.Select
Selection.Copy
ActiveCell.Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=LEFT(RC[-1],4)"
ActiveCell.Select
Selection.Copy
ActiveCell.Range("A1:A" & temp1).Select
ActiveSheet.Paste
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Range("A1:K" & temp1).Select
ActiveCell.Offset(0, 11).Range("A1").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1Local = _
"=IF(R[0]C[-1]=""laun"",""laun"", IF(R[0]C[-6]=""averages:"",""averages:"",""""))"
ActiveCell.Select
Selection.Copy
ActiveCell.Range("A1:A" & temp1).Select
ActiveSheet.Paste
ActiveCell.Offset(0, -11).Range("A1:L" & temp1).Select
Application.CutCopyMode = False
ActiveCell.Activate
Selection.AutoFilter
ActiveSheet.Range("$A$1:$L$2" & temp1).AutoFilter Field:=12, Criteria1:=Array( _
"=laun", "averages:"), Operator:=xlFilterValues