PC Review


Reply
Thread Tools Rate Thread

Checking if ranges are the same after Range.EntireColumn

 
 
jc
Guest
Posts: n/a
 
      4th Jun 2008
running the following code

If Selection = Selection Then MsgBox "ok"
If Selection.EntireColumn = Selection.EntireColumn Then MsgBox "ok"--
If Selection.EntireColumn.Cells(10) = Selection.EntireColumn.Cells(10) Then
MsgBox "ok"

the first line works
the second line results in a run-time error '13': Type mismatch
the third line works

can anyone explain why 2nd line doesn't work ?

JC
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      4th Jun 2008
In your 1st & 3rd lines Selection & .Cells(10) returns the value of a
single cell. Both sides of the = being the same the msgbox shows "ok"

In your 2nd line, Selection returns a 2d array of all cell values in the
column.
If you try and do
myArray = myArray
you will get the same error

Of course if had you selected two or more cells your 1st line would have
failed for the same reason.

Regards,
Peter T


"jc" <(E-Mail Removed)> wrote in message
news:AA61C7E8-69AE-4123-BBF6-(E-Mail Removed)...
> running the following code
>
> If Selection = Selection Then MsgBox "ok"
> If Selection.EntireColumn = Selection.EntireColumn Then MsgBox "ok"--
> If Selection.EntireColumn.Cells(10) = Selection.EntireColumn.Cells(10)

Then
> MsgBox "ok"
>
> the first line works
> the second line results in a run-time error '13': Type mismatch
> the third line works
>
> can anyone explain why 2nd line doesn't work ?
>
> JC



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      4th Jun 2008
If you're just looking to see if the selection is an entire column:

if selection.address = selection.entirecolumn.address then



jc wrote:
>
> running the following code
>
> If Selection = Selection Then MsgBox "ok"
> If Selection.EntireColumn = Selection.EntireColumn Then MsgBox "ok"--
> If Selection.EntireColumn.Cells(10) = Selection.EntireColumn.Cells(10) Then
> MsgBox "ok"
>
> the first line works
> the second line results in a run-time error '13': Type mismatch
> the third line works
>
> can anyone explain why 2nd line doesn't work ?
>
> JC


--

Dave Peterson
 
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
Join non-contiguous ranges into one range via named range? ker_01 Microsoft Excel Misc 3 1st May 2009 11:09 AM
Checking 2 Ranges =?Utf-8?B?RGF2aXY=?= Microsoft Excel Programming 4 10th Apr 2007 09:40 PM
Checking range of cells for entry then checking for total =?Utf-8?B?QmFyYiBSZWluaGFyZHQ=?= Microsoft Excel Programming 1 13th Oct 2006 02:47 PM
x y scatter chart series ranges reset to x(range) = y(range) =?Utf-8?B?QnJha2VybTE5?= Microsoft Excel Charting 4 26th Sep 2006 11:13 PM
Checking if Target is within different ranges =?Utf-8?B?TWF0dA==?= Microsoft Excel Programming 1 23rd Jul 2004 04:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:50 AM.