+ Reply to Thread
Results 1 to 6 of 6

strange result from SpecialCells

  1. #1
    Registered User
    Join Date
    10-29-2006
    Posts
    14

    strange result from SpecialCells

    Why do I get the following strange result? Cell E11 contains the single letter 'f'. In the imediate window:

    ? activesheet.range("E11").SpecialCells(xlCellTypeConstants).address
    $K$2:$N$2,$D$4,$H$4,$L$4,$R$4,$K$4:$K$5,$G$6:$Z$6, ...
    (the list is pretty long)

    while the following produces the expected result, E11.

    ? activesheet.range("E11:E12").SpecialCells(xlCellTypeConstants).address
    $E$11


    seron
    Last edited by seron; 11-20-2006 at 11:12 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486
    Quote Originally Posted by seron
    Why do I get the following strange result? Cell E11 contains the single letter 'f'. In the imediate window:

    ? activesheet.range("E11").SpecialCells(xlCellTypeConstants).address
    $K$2:$N$2,$D$4,$H$4,$L$4,$R$4,$K$4:$K$5,$G$6:$Z$6, ...
    (the list is pretty long)

    while the following produces the expected result, E11.

    ? activesheet.range("E11:E12").SpecialCells(xlCellTypeConstants).address
    $E$11


    seron
    Watcha trying to do

  3. #3
    Registered User
    Join Date
    10-29-2006
    Posts
    14
    Quote Originally Posted by davesexcel
    Watcha trying to do
    Hi Dave.

    Within a userselected range of cell I'd like to find which cells contain constant values, e.g. F, AB, N etc. The user may select one or multiple cells and they may be disjoint.

    The problem is that if the selected range is only one cell then SpecialCells(xlCellTypeConstants) produces unpredictable and seemingly random sets of cells that may be outside of the selected range. I wonder why it does that.

  4. #4
    Registered User
    Join Date
    10-29-2006
    Posts
    14
    bump

    Is there anyone who could confirm this behaviour?

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486
    kind of hard to confirm anything without the code , or what you are trying to do

  6. #6
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Seron

    It does appear that SpecialCells returns all the cells matching the constraint on a given worksheet if it is prefixed by a single cell object. So, to get areound that in code, you probably want to ascertain the size of your given range object first eg:

    Please Login or Register  to view this content.
    and put in place code to test the contents directly (eg HasFormula property or .Value="") in the case of it being a single cell.

    Richard

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1