+ Reply to Thread
Results 1 to 8 of 8

Using For Each Cell in Range() with .SpecialCells(x1CellTypeVisible) does not work

  1. #1
    Forum Contributor
    Join Date
    08-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    132

    Using For Each Cell in Range() with .SpecialCells(x1CellTypeVisible) does not work

    I have a sheet with 60,000 lines on it. By doing a simple sort, I can take out about 40,000 that I don't actually want information from.

    As these cells are imported from a different program, they contain a ton of spaces at the end, and I need to trim those off so they're viable for vlookup. I have the following code:

    Please Login or Register  to view this content.
    This works fine - but it runs on all 60,000 cells and causes me to age by a year each time I run it.

    What I'm trying to do is this:

    Please Login or Register  to view this content.
    But alas, I get an error.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Using For Each Cell in Range() with .SpecialCells(x1CellTypeVisible) does not work

    Maybe ...
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Using For Each Cell in Range() with .SpecialCells(x1CellTypeVisible) does not work

    Try:
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  4. #4
    Forum Contributor
    Join Date
    08-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: Using For Each Cell in Range() with .SpecialCells(x1CellTypeVisible) does not work

    Quote Originally Posted by OllyXLS View Post
    Try:
    Please Login or Register  to view this content.
    This does work, technically - but I'm not sure what the celltypeCosntants does - it still hits all cells from 1 - 60,000, even the hidden ones.

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Using For Each Cell in Range() with .SpecialCells(x1CellTypeVisible) does not work

    Can this help?

    Please Login or Register  to view this content.

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Using For Each Cell in Range() with .SpecialCells(x1CellTypeVisible) does not work

    Ok, so try:
    Please Login or Register  to view this content.
    Limited to visible cells within the used range of column F.

    Check the worksheet reference.

  7. #7
    Forum Contributor
    Join Date
    08-16-2010
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    132

    Re: Using For Each Cell in Range() with .SpecialCells(x1CellTypeVisible) does not work

    Quote Originally Posted by OllyXLS View Post
    Ok, so try:
    Please Login or Register  to view this content.
    Limited to visible cells within the used range of column F.

    Check the worksheet reference.
    Pardon my ignorance on this - but I'm not sure which value to change to get it to work with my sheet.

    It runs without error, but it doesn't do anything. The name of the sheet I'm working is Start. So I tried changing this to:

    Please Login or Register  to view this content.
    None of them work.

  8. #8
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Using For Each Cell in Range() with .SpecialCells(x1CellTypeVisible) does not work

    Quote Originally Posted by lordterrin View Post
    Pardon my ignorance on this - but I'm not sure which value to change to get it to work with my sheet.

    It runs without error, but it doesn't do anything. The name of the sheet I'm working is Start. So I tried changing this to:

    Please Login or Register  to view this content.
    None of them work.
    I was referring to the codename. You could equally use:
    Please Login or Register  to view this content.

+ 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. [SOLVED] Using SpecialCells(xlLastCell) in a Range
    By bishoposiris in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-21-2014, 08:45 AM
  2. VBA Range.SpecialCells( xlCellTypeVisible ) not working as a UDF
    By dwk49 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-29-2012, 05:29 AM
  3. VBA ON ERROR does not work with SPECIALCELLS
    By Felix in forum Excel General
    Replies: 5
    Last Post: 06-27-2012, 07:05 AM
  4. .SpecialCells(xlLastCell).Select does not work in vbscript
    By ckb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-18-2007, 12:58 PM
  5. [SOLVED] Doesn't work as it SHOULD .. Rows.Hidden /with SpecialCells
    By Gunnar Johansson in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-01-2006, 06:25 AM

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