+ Reply to Thread
Results 1 to 3 of 3

Loop Column reference in VBA Countif

  1. #1
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Loop Column reference in VBA Countif

    Could somebody help me with this loop? I would like to compact this Countif to just a single line with the variable being passing thru as columns.

    I can fix the half to the left of the equal sign, but how can can I loop the column numbers? My attempts so far have failed so any help is appreciated.

    The columns to loop are 20, 4, 38, and 4, but of course there are more which I can easily put in once set on the right path.

    The 2nd criteria range in the Countif is always the same with the 2nd criteria already run through a For Each structure.

    Please Login or Register  to view this content.
    Edit: I attached a sample workbook but limited the columns
    Attached Files Attached Files
    Last edited by jeffreybrown; 10-14-2016 at 08:00 PM.
    HTH
    Regards, Jeff

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,414

    Re: Loop Column reference in VBA Countif

    Hello Jeff,

    Here's a suggestion. Different loop structure but only one countif formula:

    Please Login or Register  to view this content.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Loop Column reference in VBA Countif

    Thanks GC, works perfectly...

+ 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] (Beginner help) For loop inside do loop that displays information from reference sheet.
    By lediable007 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-08-2016, 03:20 PM
  2. Why is my nested countif loop wrong
    By falco008 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-22-2016, 06:07 AM
  3. [SOLVED] For Loop nested in For Each Loop - Use For Each's [item] as row reference
    By Schluensen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-28-2014, 11:37 PM
  4. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  5. [SOLVED] Loop till end of the sheet and loop back to first column again
    By smlim7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-29-2012, 10:03 AM
  6. Loop a column on Sheet1 and loop a row on Sheet2 to find a match
    By johnnywinter in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-13-2009, 02:09 PM
  7. [SOLVED] For Each ... Next loop - need to reference the loop variable
    By neonx3@yahoo.ca in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-13-2006, 01: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