+ Reply to Thread
Results 1 to 17 of 17

No cells found - SpecialCells Constants, 23 - don't understand

  1. #1
    Registered User
    Join Date
    07-18-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    30

    No cells found - SpecialCells Constants, 23 - don't understand

    Hello,

    I have a code to populate visible cells which works fine on its own (eg. If I auto-filter manually & then run it) but its not working within this code I wrote to automate my filtering & I don't know why.

    Code is below.The De-Bugger highlighted the line "Set r2 = r1.SpecialCells(xlCellTypeConstants, 23)" and said that No Cells Found. But on the spreadsheet the Macro has successfully filtered for those cells and there are cells waiting to be populated. On my first filter (=4), all cells in column E are Blank - I don't know whether that has anything to do with it, but the Labelling code was written to handle both blank & non-blank cells.

    The structure I was trying to put together is Insert Row(once only)/Auto-Filter1/Label1/Undo-FIlter1/Auto-Filter2/Label2.

    My searching so far has not found the solution to why this code does not work - would greatly appreciate someone's advice. I am learning alot through this process.

    Please Login or Register  to view this content.
    Thanks,
    Trent

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    Attaching a sample workbook enables others to work on your problem:

    To attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include BEFORE/AFTER sheets if needed to show the process you're trying to complete or automate. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  3. #3
    Registered User
    Join Date
    07-18-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    Attached is my before and after. My macro inserts a blank column to be located as column E & filters column AI for =4, populates column E with "Pattern 1", undo filter, then filter column AJ for =5, then populate column E with "Pattern 2". Here is the macro code I was trying to use but its not working.
    NOTE : My actual filters are more complicated - I am just trying to get the structure of the VBA correct andI can do the rest.

    Advice on what is wrong with this would be much appreciated.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    Please Login or Register  to view this content.
    constant means non blank and you are trying to assign blank columns E range in to it, hence for the error

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    I can't open your workbooks.

  6. #6
    Registered User
    Join Date
    07-18-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    Hello,

    Maybe try open my workbooks now. I had to change version.

    Some cells in column E will be Non-Blank after "Pattern 1" label is populated there & my section of code being used to populate those Pattern names is meant to accommodate where one record will be both (eg " Pattern 1//Pattern 2" - how do I keep that functionality but avoid this Range definition conflict ?
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    Quote Originally Posted by davesexcel View Post
    I can't open your workbooks.
    Hi Dave,
    Interesting!
    I have downloaded office 365 with office 2013 in to PC, but had excel 2010 already installed. All my existing excel books are turned in to excel 2013 version.
    I am also unable to download the attached book, but the error message was something to do with version compatibility.
    I managed to download the same attached on a different PC which has excel 2003.
    I am now worried that there may be compatibility issues.
    I still have excel 2010 on my tab top.
    Do you know if I can still open excel 2003 files in 2013?

  8. #8
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    That is strange,
    I have opened .xls files many times,
    The files by OP are .xlsx extentions, both xl'10 & xl'13 cant open them, says file extension error.

    But you managed to open them with xl'03 with a xlsx converter?

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    Ohm,
    I did not even notice it was xlsx. I managed to open the last attached in excel 2013.

  10. #10
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,274

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    The first two are actually .xls files but have been given an .xlsx extension for some reason.
    Remember what the dormouse said
    Feed your head

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    Hi Rory,
    I get a weekly e-mail from a client. The client attached two sheets, one with xls extension and the other one as xlsx. I can open both files from excel 2010. I can not open the xlsx in 2003, but can open xls.
    I do not even know how this xlsx file is created.
    What worried me is the compatibility issue. It is all good for MS to realise new versions every 2 years, but remain silent when people are locked-in version and too late to do anything.

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,274

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    There is a compatibility pack for 2003 that allows you to open the newer format files, although some of the newer functionality won't work. I think support for 2003 is over now anyway.

  13. #13
    Registered User
    Join Date
    07-18-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    Hi all,

    Grateful for the attention you've provided my thread here.

    Without the Before, After files opening I should just say that my above code was just trying to run this sequence : Insert column E(once only)/Auto-Filter1/Label1/Undo-FIlter1/Auto-Filter2/Label2(where cell is already Label1, it becomes "Label1/Label2"). I am needing a macro because in reality my Auto-filters are extremely complex.

    I was thinking my macro code (copied below) would work because the sections of code that populate column E seems to work when I have filtered manually. All I have done is Recorded a macro and copied/pasted it all together.

    If I can't use that line r1.SpecialCells(xlCellTypeConstants, 23) because non-blank doesn't match with the initial state of column E (which is blank to begin with) could someone please advise what my alternative is ? Column E certainly begins Blank, but after "Pattern 1" is populated, when its time for "Pattern 2" to be populated, some cells are both and its meant to show "Pattern 1/Pattern 2".

    Again, I am mostly learning through Recording macros and this forum but knowing the correct syntax to define is something I largely get from reading posts, so anyone's help on this would be greatly appreciated. Thanks very much,Trent.

    Just so you don't need to scroll all the way up again, my code is as follows:
    Please Login or Register  to view this content.

  14. #14
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    Your original thread, you had a code
    If (cell.Value <> "") Then
    cell.Value = cell.Value & "//Pattern 3"
    Else cell.Value = "Pattern 3"
    I supplied you with a code that selected the Blank cells and one that selected the non-blank cells. If you don't have blank cells, then remove that part of the code.

  15. #15
    Registered User
    Join Date
    07-18-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    My first code using Else wasnt filling my whole column and i thought it was a memory issue but when i used Your code (using SpecialCells) which also caters for labelling when the cell has already been labelled by Pattern 1 (eg. "Pattern 1/Pattern2") worked so Ive just I inserted your code into a sequence that includes my auto-filtering. Column E is blank to begin with but depending in the auto-filter could also be only blank visible cells later also - just need a labelling code that checks the visible cells and works like an IF ELSE....but that original code was stopping halfway for no reason(my spreadsheet was20000 rows and 60 columns and I concluded it may have been memory.

    Is there an Else line I can incorporate into a SpecialCells instruction or do they not work like that?

    Thanks for your consideration of my problem

  16. #16
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    If you are inserting the column, then you don't need to search for blanks or none blanks, just have to search for visible cells.

    Please Login or Register  to view this content.

  17. #17
    Registered User
    Join Date
    07-18-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: No cells found - SpecialCells Constants, 23 - don't understand

    The reason I need to make a distinction is that after each Pattern is labelled (& I have around 15 Patterns) some records have multiple patterns applying so I need to populate those cells as CellValue&"//Pattern 6" where Cell Value is already Pattern 2 or whatever previous label applied.

    I have figured out a solution though not ideal - I type something into E1 as part of the macro and include E1 in the range for SpecialCells so after all patterns are labelled E1 had a lot of text but all the data below had been correctly labelled.

    I hope you could see where I was coming from. It's a pity the IF ELSE didn't work but I thought there would have been a more elegant solution.

    You've helped me reach an end that is functional enough and I'm very grateful for your time.

    Regards
    Trent

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Trying to add text to the end of non-blank cells using SpecialCells
    By fallwire in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2015, 08:07 AM
  2. [SOLVED] Is it possibe to error trap Range.SpecialCells(xlCellTypeConstants) if found > 1?
    By kjy1989 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2013, 07:34 PM
  3. Autofiltering, copying cells and specialcells
    By jlt199 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 03-31-2010, 07:44 PM
  4. Excel03 - empty cells and SpecialCells ( xlVisible )
    By Chris Paterson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-23-2005, 10:05 AM
  5. .Cells.SpecialCells(xlLastCell)
    By Simon Shaw in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-05-2005, 07:06 PM

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