+ Reply to Thread
Results 1 to 3 of 3

Return the number of columns with value within a custom range

  1. #1
    Registered User
    Join Date
    03-29-2021
    Location
    Netherlands
    MS-Off Ver
    2013
    Posts
    2

    Return the number of columns with value within a custom range

    Hello excelforum, I am new here and with creating macros.

    As of now I am trying to wrap my brain about counting the amount of columns with data in a worksheet. I see for example UsedRange.Columms.Count is a way but I cannot figure out how to use with a custom range. What I basically want to do is count how many columns in the range of C9:E23 have any value in it. (e.g. if there's any value in C, D and E in the range C9:E23, it returns 3). But any attempt of combining it with Range("C9:E23") returns errors.

    On recommendation of someone else I also tried Range("C9:E23").SpecialCells(xlTextValues + xlNumbers).Columns.Count but this returns a 1004 Application defined or object defined error.

    Am I looking in the wrong spot? Any help is deeply appreciated.

  2. #2
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Return the number of columns with value within a custom range

    A sample would make it easier. follow the instructions in the yellow banner

    if you are only 3 columns in reality

    (counta(c9:c23)>0)+(counta(c9:c23)>0)+(counta(c9:c23)>0) could be a starting point, it is not entirely clear if it is this x 3 of just this, or

    if((counta(c9:c23)>0)*(counta(c9:c23)>0)*(counta(c9:c23)>0) =1,3,"")
    Last edited by davsth; 04-01-2021 at 06:54 AM.

  3. #3
    Registered User
    Join Date
    03-29-2021
    Location
    Netherlands
    MS-Off Ver
    2013
    Posts
    2
    Thanks alot for your suggestion! I will try it out. Apologies my post is a bit bareboned, due to strict internet settings at my current location, I type it out by phone. If needed I will provide more context later.
    Last edited by AliGW; 04-01-2021 at 05:31 AM. Reason: PLEASE don't quote unnecessarily!

+ 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] Looking for formula to return custom value based on maximum value from range
    By Sammydasalmon in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-21-2021, 09:45 PM
  2. [SOLVED] Power Query Custom Column: If number in columns a or b are less than 1 then 0 else 1
    By jekeith in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-15-2018, 10:31 AM
  3. [SOLVED] return FROM TO values from custom defined range , and return all possible combination
    By raj soni in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2016, 01:38 PM
  4. Query date range and ref number match to return another reference number
    By 27paul0 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-09-2015, 07:31 AM
  5. [SOLVED] How2 find number in range and return that number or if doesn't exist then the next highest
    By Crawfinator1 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 06-06-2014, 08:52 AM
  6. Find Custom Formated Number In Cell Range
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-01-2011, 07:47 PM
  7. [SOLVED] custom function - return range
    By GinaW in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-19-2006, 07:15 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