run-time error 1004: Application-defined or object-defined error

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
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi

Perhaps change that line to this -

ActiveSheet.Range("$A$1:$L$" & temp1).AutoFilter Field:=12, Criteria1:=Array( _
"=laun", "averages:"), Operator:=xlFilterValues


hth
 
Upvote 0
Hi,

Thank you very much for your updates.
Your logic is working well.

Can you update the understanding/logic like when the value is removed, its working.;)
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,282
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top