Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default MACRO not working on two different files

I have the code below on my PERSONAL workbook and works fine. When I try to
copy it to another workbook, it doesn't get past the first RANGE line. The
error I get is "Select Method of Range class Failed."

Why would this happen?

Thanks.


Company = InputBox("For which Company is this TB for?", "Company Code",
"112, 115, 127, 176, 177")
ChDir "C:\Documents and Settings\marco.rodas\Desktop"
Workbooks.OpenText Filename:= _
"C:\Documents and Settings\marco.rodas\Desktop\Trial Balance
TEMP.txt", Origin:= _
xlWindows, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, _
1), Array(1, 1), Array(13, 1), Array(34, 1), Array(75, 1), Array(94,
1), Array(113, 1))
Range("B11:G20192").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.AutoFilter
Selection.AutoFilter Field:=3, Criteria1:="=" & Company & "*",
Operator:=xlAnd
Selection.Copy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default MACRO not working on two different files

Try adding activesheet just ahead of the range statements...

Activesheet.Range("B11:G20192").Select
Activesheet.Range(Selection, Selection.End(xlDown)).Select

--
HTH...

Jim Thomlinson


"Marco" wrote:

I have the code below on my PERSONAL workbook and works fine. When I try to
copy it to another workbook, it doesn't get past the first RANGE line. The
error I get is "Select Method of Range class Failed."

Why would this happen?

Thanks.


Company = InputBox("For which Company is this TB for?", "Company Code",
"112, 115, 127, 176, 177")
ChDir "C:\Documents and Settings\marco.rodas\Desktop"
Workbooks.OpenText Filename:= _
"C:\Documents and Settings\marco.rodas\Desktop\Trial Balance
TEMP.txt", Origin:= _
xlWindows, StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(Array(0, _
1), Array(1, 1), Array(13, 1), Array(34, 1), Array(75, 1), Array(94,
1), Array(113, 1))
Range("B11:G20192").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.AutoFilter
Selection.AutoFilter Field:=3, Criteria1:="=" & Company & "*",
Operator:=xlAnd
Selection.Copy

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
working with .txt files in a macro Peggy Excel Discussion (Misc queries) 3 January 14th 08 02:26 PM
Working with XML Files scantor145[_6_] Excel Programming 2 June 23rd 05 03:38 PM
Working through files in a directory nath Excel Programming 1 June 14th 04 01:04 PM
Working with PDF files in VBA Vicki Main Excel Programming 1 May 3rd 04 03:01 PM
Working with other files steve Excel Programming 1 April 29th 04 06:42 PM


All times are GMT +1. The time now is 10:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"