+ Reply to Thread
Results 1 to 15 of 15

Name ranges, but stop at blanks or error cells

  1. #1
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    756

    Name ranges, but stop at blanks or error cells

    Hi all,

    On the attached I have some tables. They can contain up to 20 values in the 2nd column, i.e. C4:C23 in the first table.

    Once this data is produced, I have a code to name the ranges, which works when a table is the only table in a single sheet.

    If I run the code below, it selected everything B2 downwards and gives it a name, which selected the two tables on the left.

    Please Login or Register  to view this content.
    Ultimately, I am looking to amend this code so that it does not select any blank columns, or where there are any errors in the cells - so for example

    - with the first table it would select B2:G13.
    - with the second table it would select I3:P23
    - the third table (bottom left) it would select B25:G24
    - the fourth table (bottom right) it would select I26:P46

    Anyone have any ideas how to go about this?

    Cheers,

    Chris
    Attached Files Attached Files

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,273

    Re: Name ranges, but stop at blanks or error cells

    I'm surprised that you still get assistance...
    So many of your threads are unanswered...
    Here
    Here
    Here
    Here
    Just to list a few...
    Last edited by sintek; 10-31-2022 at 02:13 PM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    756

    Re: Name ranges, but stop at blanks or error cells

    Hi Sintek,

    Many thanks for your response.

    Re those threads they still remain live while I carry out testing, as I work with complicated and sensitive data.

    I apologise for any inconvenience I have caused.

    Kind Regards,

    Chris

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,541

    Re: Name ranges, but stop at blanks or error cells

    Re those threads they still remain live while I carry out testing, as I work with complicated and sensitive data.
    I suspect that, had you shared that information in each thread, the contributors may feel more understanding.

    Reality check: a couple of the threads highlighted are over a month old.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,273

    Re: Name ranges, but stop at blanks or error cells

    Thank you for taking care of your unanswered threads...
    On the attached I have some tables
    Your sample file contains no Tables and does not match your explanation...
    Upload an accurate representation of your file in explain in detail what it is you would want this code to do...

  6. #6
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    756

    Re: Name ranges, but stop at blanks or error cells

    Apologies, I've uploaded the wrong file

    Please see the attached.
    Attached Files Attached Files

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,273

    Re: Name ranges, but stop at blanks or error cells

    Does not match this...
    - with the first table it would select B2:G13.
    - with the second table it would select I3:P23
    - the third table (bottom left) it would select B25:G24
    - the fourth table (bottom right) it would select I26:P46
    As per post 5...
    Upload an accurate representation of your file in explain in detail what it is you would want this code to do...
    And why oh why would you merge cells!!! It causes havoc with VBA

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,541

    Re: Name ranges, but stop at blanks or error cells

    Can't you just use:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    756

    Re: Name ranges, but stop at blanks or error cells

    Hi Sintek.

    So atm when I run the code shown in my first post, it would select B2:G46 - selecting the two tables on the left-hand side, and naming them as one range.

    I am looking at how I could amend the code, to only select B2:G23, or ideally B2:G13 as this range is the range in this table with data.

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,273

    Re: Name ranges, but stop at blanks or error cells

    Get rid of those merged cells...
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    756

    Re: Name ranges, but stop at blanks or error cells

    Thanks Sintek - the used range in those tables would be name "TopContacts1" "Top Contacts2" and so on.

  12. #12
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,273

    Re: Name ranges, but stop at blanks or error cells

    Here you go...
    Please Login or Register  to view this content.
    Thanks for rep +

  13. #13
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    756

    Re: Name ranges, but stop at blanks or error cells

    Fantastic sintek! That is brilliant.

  14. #14
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,541

    Re: Name ranges, but stop at blanks or error cells

    Thanks for the rep.

  15. #15
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    756

    Re: Name ranges, but stop at blanks or error cells

    Thanks TMS, I've used IFERROR on my ranking formula to tidy it up a bit, so it looks better! Much appreciated.

+ 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] Stop blanks showing as Zeros
    By 90yeomana in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-29-2020, 12:27 PM
  2. Replies: 1
    Last Post: 07-05-2016, 06:35 AM
  3. [SOLVED] Stop counting the blanks in formula
    By Biogeek1 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-05-2013, 02:48 PM
  4. [SOLVED] SUMPRODUCT #VALUE Error - Req it to look at split ranges and treat blanks as 1
    By marsham in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-20-2013, 06:18 PM
  5. sum product counting blanks, how can i stop it!
    By xenohadden in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-13-2012, 09:18 AM
  6. How to stop vba error when pasting a range of cells
    By alanb1976 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-15-2012, 07:42 AM
  7. Replies: 0
    Last Post: 08-25-2005, 03:40 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