Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
JAtz_DA_WAY
 
Posts: n/a
Default Run time error 9 : Subscript out of range


Hi All,

I was trying to execute the macro on the link:
http://www.exceltip.com/st/Compare_t...ce l/477.html

But I get the error: "Run time error 9 : Subscript out of range" when I
try to compare 2 workbooks.

The line where i get error is:

CompareWorksheets ActiveWorkbook.Worksheets("Sheet1"), _
Workbooks("WorkBookName.xls").Worksheets("Sheet2")

I even tried renaming the file on my system to workbookname.xls.....but
it just doeesnt work.

Please advise...

Regards,

Jatz


--
JAtz_DA_WAY
------------------------------------------------------------------------
JAtz_DA_WAY's Profile: http://www.excelforum.com/member.php...o&userid=26684
View this thread: http://www.excelforum.com/showthread...hreadid=399567

  #2   Report Post  
Chip Pearson
 
Posts: n/a
Default

You'll get a run time error 9 when the specified item is not in
the collection. Are you sure the workbooks have sheets named
'Sheet1' and 'Sheet2'?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"JAtz_DA_WAY"
wrote
in message
...

Hi All,

I was trying to execute the macro on the link:
http://www.exceltip.com/st/Compare_t...ce l/477.html

But I get the error: "Run time error 9 : Subscript out of
range" when I
try to compare 2 workbooks.

The line where i get error is:

CompareWorksheets ActiveWorkbook.Worksheets("Sheet1"), _
Workbooks("WorkBookName.xls").Worksheets("Sheet2")

I even tried renaming the file on my system to
workbookname.xls.....but
it just doeesnt work.

Please advise...

Regards,

Jatz


--
JAtz_DA_WAY
------------------------------------------------------------------------
JAtz_DA_WAY's Profile:
http://www.excelforum.com/member.php...o&userid=26684
View this thread:
http://www.excelforum.com/showthread...hreadid=399567



  #3   Report Post  
JAtz_DA_WAY
 
Posts: n/a
Default


Thanks for the quick reply...

Yes. The sheets are names sheet1 & sheet2.

It works fine if i change the statement :
-CompareWorksheets ActiveWorkbook.Worksheets("Sheet1"),
Workbooks("c1.xls").Worksheets("Sheet2")-
to

-'CompareWorksheets ActiveWorkbook.Worksheets("Sheet1"),
ActiveWorkbook.Worksheets("Sheet2")-

But this way I will be comparing sheets in the same workbook & not the
different ones.

Thanks in advance...
Regards,

Jatz


--
JAtz_DA_WAY
------------------------------------------------------------------------
JAtz_DA_WAY's Profile: http://www.excelforum.com/member.php...o&userid=26684
View this thread: http://www.excelforum.com/showthread...hreadid=399567

  #4   Report Post  
JAtz_DA_WAY
 
Posts: n/a
Default


Any Answers Please ???


--
JAtz_DA_WAY
------------------------------------------------------------------------
JAtz_DA_WAY's Profile: http://www.excelforum.com/member.php...o&userid=26684
View this thread: http://www.excelforum.com/showthread...hreadid=399567

  #5   Report Post  
JAtz_DA_WAY
 
Posts: n/a
Default


And also in the same directory !!


--
JAtz_DA_WAY
------------------------------------------------------------------------
JAtz_DA_WAY's Profile: http://www.excelforum.com/member.php...o&userid=26684
View this thread: http://www.excelforum.com/showthread...hreadid=399567



  #6   Report Post  
Dave Peterson
 
Posts: n/a
Default

This macro requires that c1.xls be open, too.

Is it?

And are you sure you have the correct name--it's c1.xls. That second character
is a 1 (one), not an L (ell).

And are you sure that there is a worksheet named Sheet1 in the activeworkbook
and a worksheet named Sheet2 in that c1.xls workbook?

JAtz_DA_WAY wrote:

Thanks for the quick reply...

Yes. The sheets are names sheet1 & sheet2.

It works fine if i change the statement :
-CompareWorksheets ActiveWorkbook.Worksheets("Sheet1"),
Workbooks("c1.xls").Worksheets("Sheet2")-
to

-'CompareWorksheets ActiveWorkbook.Worksheets("Sheet1"),
ActiveWorkbook.Worksheets("Sheet2")-

But this way I will be comparing sheets in the same workbook & not the
different ones.

Thanks in advance...
Regards,

Jatz

--
JAtz_DA_WAY
------------------------------------------------------------------------
JAtz_DA_WAY's Profile: http://www.excelforum.com/member.php...o&userid=26684
View this thread: http://www.excelforum.com/showthread...hreadid=399567


--

Dave Peterson
  #7   Report Post  
JAtz_DA_WAY
 
Posts: n/a
Default


Thanks Dave, After opening the file & executing the macro, it works.

Regards,

Jatz


--
JAtz_DA_WAY
------------------------------------------------------------------------
JAtz_DA_WAY's Profile: http://www.excelforum.com/member.php...o&userid=26684
View this thread: http://www.excelforum.com/showthread...hreadid=399567

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
My Quest with Time!! Philip Excel Worksheet Functions 4 August 24th 05 01:09 PM
Adding time damezumari Excel Discussion (Misc queries) 2 June 20th 05 08:35 PM
help with date and time wayne visser Excel Worksheet Functions 1 June 14th 05 04:10 PM
unmet challenge boris Excel Worksheet Functions 2 March 16th 05 02:13 PM
Define a range based on another named range Basil Excel Worksheet Functions 2 February 21st 05 01:47 PM


All times are GMT +1. The time now is 01:18 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"