PC Review


Reply
Thread Tools Rate Thread

Compare Two Sheets Generates Runtime Error 13

 
 
=?Utf-8?B?cnlndXk3Mjcy?=
Guest
Posts: n/a
 
      26th Oct 2007
For several weeks the macro below worked fine:
Sub Compare2Shts()
For Each Cell In Worksheets("Primary").UsedRange
If Cell.Value <> Worksheets("Secondary").Range(Cell.Address) Then
Cell.Interior.ColorIndex = 3
End If
Next

For Each Cell In Worksheets("Secondary").UsedRange
If Cell.Value <> Worksheets("Primary").Range(Cell.Address) Then
Cell.Interior.ColorIndex = 3
End If
Next
End Sub



It would compare values in two sheets, and highlight any differences in red.
Today, all of a sudden, it just started erroring out at this line:
If Cell.Value <> Worksheets("Secondary").Range(Cell.Address) Then

I get a message saying “Run-time error 13”. This is quite bizarre because,
as far as I can tell, nothing changed in the data set. Does anyone have any
suggestions as to what may cause this?


Kind Regards,
Ryan---


--
RyGuy
 
Reply With Quote
 
 
 
 
Jim Cone
Guest
Posts: n/a
 
      26th Oct 2007

Ryan,
You possibly have an error value in one of the cells being compared.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"ryguy7272"
wrote in message
For several weeks the macro below worked fine:
Sub Compare2Shts()
For Each Cell In Worksheets("Primary").UsedRange
If Cell.Value <> Worksheets("Secondary").Range(Cell.Address) Then
Cell.Interior.ColorIndex = 3
End If
Next

For Each Cell In Worksheets("Secondary").UsedRange
If Cell.Value <> Worksheets("Primary").Range(Cell.Address) Then
Cell.Interior.ColorIndex = 3
End If
Next
End Sub

It would compare values in two sheets, and highlight any differences in red.
Today, all of a sudden, it just started erroring out at this line:
If Cell.Value <> Worksheets("Secondary").Range(Cell.Address) Then
I get a message saying “Run-time error 13”. This is quite bizarre because,
as far as I can tell, nothing changed in the data set. Does anyone have any
suggestions as to what may cause this?

Kind Regards,
Ryan---
--
RyGuy

 
Reply With Quote
 
=?Utf-8?B?cnlndXk3Mjcy?=
Guest
Posts: n/a
 
      26th Oct 2007
Something in one of the far right-hand columns caused it to fail. Whatever
it is, it is very weird! I just changed the compare range; now the macros is
like this:
Sub Compare2Shts()
For Each Cell In Worksheets("Primary").Range("A1000:Z2500")
If Cell.Value <> Worksheets("Secondary").Range(Cell.Address) Then
Cell.Interior.ColorIndex = 3
End If
Next
etc...

I have no idea what it was...just one of those formatting-things I guess.
Maybe error value accidentally got into the UsedRange or something...who
knows. I learned a long time ago, just because you can't see some kind of
data (i.e. a space) doesn't mean that some kind of data is not there.

Thanks for the look Jim!!
Ryan---

--
RyGuy


"Jim Cone" wrote:

>
> Ryan,
> You possibly have an error value in one of the cells being compared.
> --
> Jim Cone
> San Francisco, USA
> http://www.realezsites.com/bus/primitivesoftware
> (Excel Add-ins / Excel Programming)
>
>
>
> "ryguy7272"
> wrote in message
> For several weeks the macro below worked fine:
> Sub Compare2Shts()
> For Each Cell In Worksheets("Primary").UsedRange
> If Cell.Value <> Worksheets("Secondary").Range(Cell.Address) Then
> Cell.Interior.ColorIndex = 3
> End If
> Next
>
> For Each Cell In Worksheets("Secondary").UsedRange
> If Cell.Value <> Worksheets("Primary").Range(Cell.Address) Then
> Cell.Interior.ColorIndex = 3
> End If
> Next
> End Sub
>
> It would compare values in two sheets, and highlight any differences in red.
> Today, all of a sudden, it just started erroring out at this line:
> If Cell.Value <> Worksheets("Secondary").Range(Cell.Address) Then
> I get a message saying “Run-time error 13”. This is quite bizarre because,
> as far as I can tell, nothing changed in the data set. Does anyone have any
> suggestions as to what may cause this?
>
> Kind Regards,
> Ryan---
> --
> RyGuy
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code Works Fine in Excel 2007, Excel 2000 generates Runtime Error 438 Safari Microsoft Excel Programming 0 25th Jun 2009 03:53 PM
Macro generates "Type Mismatch Runtime error" Paul3rd Microsoft Excel Programming 5 27th Dec 2007 06:36 PM
Runtime error with sheets.add =?Utf-8?B?aXR0YWM=?= Microsoft Excel Programming 2 10th Aug 2005 09:40 AM
Re: Print Preview Mode - Generates extra sheets Lady Layla Microsoft Excel Misc 0 3rd Aug 2004 10:02 PM
Logbook generates runtime error 438 on another network computer Jim Robertson Microsoft Excel Programming 4 7th Oct 2003 12:03 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:42 PM.