+ Reply to Thread
Results 1 to 4 of 4

Function - Count User Defined Columns in a Range

  1. #1
    Registered User
    Join Date
    06-12-2009
    Location
    Chester, NY
    MS-Off Ver
    Excel 2013
    Posts
    89

    Function - Count User Defined Columns in a Range

    So, one of my issues with vlookup is if you have a large range it's a pain to count columns for a very wide range quickly. I'm doing some VBA training and would like to create a user defined function to accomplish this.

    So, I thought I'd create a function "CountColumns" that would be used like this =CountColumns(column 1, column 2) and it would return the distance between them.

    So...
    =CountColumns(A, D)
    Would = 4.

    In my function, here's what I had so far. Can anyone help? Still learning.

    Please Login or Register  to view this content.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Function - Count User Defined Columns in a Range

    So, one of my issues with vlookup is if you have a large range it's a pain to count columns for a very wide range quickly.
    Very true, have you considered using MATCH to do the counting for you?

    or just use index/match combo?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    06-12-2009
    Location
    Chester, NY
    MS-Off Ver
    Excel 2013
    Posts
    89

    Re: Function - Count User Defined Columns in a Range

    I could, but I thought this would be a cool way to help me learn vba and create a useful function.

  4. #4
    Registered User
    Join Date
    06-12-2009
    Location
    Chester, NY
    MS-Off Ver
    Excel 2013
    Posts
    89

    Re: Function - Count User Defined Columns in a Range

    Any ideas?

+ 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] Averaging a user input defined range based on values in columns
    By smit.etha in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-14-2014, 02:21 AM
  2. Count columns and rows from a defined range
    By piercebrosnan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-22-2013, 02:59 PM
  3. user defined function receiving a range as parameter
    By Marc in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-14-2005, 03:05 PM
  4. User defined function to count pay days in current month.
    By dbmathis in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-28-2005, 09:05 PM
  5. Passing a named range into a user defined function
    By Simon Shaw in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2005, 06: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