Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
jc jc is offline
external usenet poster
 
Posts: 164
Default Checking if ranges are the same after Range.EntireColumn

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Checking if ranges are the same after Range.EntireColumn

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" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Checking if ranges are the same after Range.EntireColumn

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
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
Checking 2 Ranges Daviv Excel Programming 2 April 10th 07 07:34 PM
Checking for nonblank cells in ranges Barb Reinhardt Excel Programming 3 October 13th 06 05:20 PM
Checking range of cells for entry then checking for total Barb Reinhardt Excel Programming 1 October 13th 06 02:47 PM
Checking for named ranges in a workbook loopoo[_17_] Excel Programming 2 November 22nd 05 05:10 PM
Checking if Target is within different ranges Matt Excel Programming 1 July 23rd 04 04:18 PM


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