+ Reply to Thread
Results 1 to 5 of 5

Use cell value as a variable counter (e.g. i, j)

  1. #1
    Registered User
    Join Date
    07-03-2019
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    2

    Use cell value as a variable counter (e.g. i, j)

    Dear all,

    I want to calculate simple median of the area of cells. The problem is, the number of cells per slide don't change linearly. For example in the first slide (shown in yellow), there are five cells with respective areas in column B. In the next slide, there are four cells (blue), etc. I have created two index columns (Index1, Index2) that mark the start and end of each slides. Now, I want to calculate the median of area in each slide as F2=MEDIAN(B(C2):B(D2)), F3= MEDIAN(B(C3):B(D3)), etc. However, these type of referencing is obviously not defined by Excel and creates error. Anybody knows how to get around this?

    Cheers,
    Shahed

    Excel problem.jpg

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Use cell value as a variable counter (e.g. i, j)

    Perhaps = MEDIAN(INDEX($B$2:$B$100,$C2):INDEX($B$2:$B$100,$D2))

    Adapt ranges and pull down as required

    (Also possible with the INDIRECT function, but that is volatile

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

    Re: Use cell value as a variable counter (e.g. i, j)

    was going to use offset but volatile so yours is better Pepe

    but perhaps a slight amendment
    =MEDIAN(INDEX($B$1:$B$100,$C2):INDEX($B$1:$B$100,$D2))

    if we had had an answer it would be easier to confirm!

  4. #4
    Registered User
    Join Date
    07-03-2019
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    2

    Re: Use cell value as a variable counter (e.g. i, j)

    I was just about to post that there was a slight miscalculation with the first formula. It worked for the first row, but not the other ones.

    Attachment 630678

    Yours work like a charm!

    Attachment 630679

    Cheers to both of you! It saved my day

  5. #5
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Use cell value as a variable counter (e.g. i, j)

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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] correctly 'wording' a for/next loop using a variable counter and variable filter
    By DBoyd121 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-14-2016, 06:13 PM
  2. [SOLVED] How to set a variable in combination with a looping x counter
    By herbie226 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-10-2016, 02:48 PM
  3. Require a counter with more than one variable
    By Runce in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-19-2014, 04:20 AM
  4. paste many rows and add a counter variable
    By IonVasi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-06-2013, 10:55 PM
  5. Adding a counter variable to code
    By nav505 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-14-2013, 08:28 PM
  6. Using counter variable as cell reference
    By riwiseuse in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-22-2010, 03:03 PM
  7. [SOLVED] Counter variable in For Loop
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-08-2006, 02:00 PM

Tags for this Thread

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