+ Reply to Thread
Results 1 to 5 of 5

Macro to Determine Length from Middle of Column

  1. #1
    Registered User
    Join Date
    06-06-2013
    Location
    Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    38

    Macro to Determine Length from Middle of Column

    I currently have a post that has been unanswered, so in trying to work it out myself I have a more specific question.
    In the middle of my spreadsheet are two columns of data I'm working with, that will eventually be involved in an if statement.

    I need a macro to count the cells filled in Column G for example versus Column H, except it won't be from G1 or H1.
    It'll always be the same starting point, so let's say G20 and H20.
    So the macro should somehow select that cell then count how long that range is and be able to dimension it.

    Then my if statement could say if rangeG > rangeH then ect.

    So basically I need a code to dimension a range by counting it, but to be able to start from the middle of the range.
    This is what I currently have that won't work for any starting point except G1:

    Please Login or Register  to view this content.
    Thank you in advance!!

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to Determine Length from Middle of Column

    Hi,

    Can't you just use

    =COUNTA(G20:G100)

    or whatever your range is?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    06-06-2013
    Location
    Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Macro to Determine Length from Middle of Column

    The length of the range will be changing. So I need the macro to determine the length having only been given the starting cell.

  4. #4
    Forum Contributor
    Join Date
    10-27-2013
    Location
    Columbus Ohio
    MS-Off Ver
    Excel 2010
    Posts
    137

    Re: Macro to Determine Length from Middle of Column

    Would it be possible to divide rangeG in half and then apply that to a new starting range as opposed to G1? I'm not on acomputer with excel at the moment or I would try it out.

  5. #5
    Registered User
    Join Date
    06-06-2013
    Location
    Wisconsin
    MS-Off Ver
    Excel 2010
    Posts
    38

    Re: Macro to Determine Length from Middle of Column

    I'm not sure. Another idea I had was to count the entire column G, then subtract the known starting range of G1:G20.
    But I don't know if it's possible to have a range dimensioned like that??

+ 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. Need help with Macro to autofill formula in Column B based on length of Column A
    By soxsrules in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-06-2013, 02:43 PM
  2. Determine Length in a Macro
    By HangMan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-10-2013, 05:27 PM
  3. Determine Length of Breaks Between Shifts
    By nathanB in forum Excel General
    Replies: 0
    Last Post: 01-08-2013, 12:46 PM
  4. How to determine Length
    By Dohko in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-28-2007, 02:40 PM
  5. Determine Length of Service
    By TheLeafs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-03-2006, 03:10 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