+ Reply to Thread
Results 1 to 3 of 3

IF statement based on a counter

  1. #1
    Registered User
    Join Date
    09-06-2016
    Location
    Daejeon, Republic of Korea
    MS-Off Ver
    2013
    Posts
    1

    Question IF statement based on a counter

    Hello!

    I want to know how can I use IF statement (in maybe a for or while loop) to change the value of the cell based on a condition of a counter.

    "=If(Counter=1,M2,if(Counter=2,M3,if(Counter=3,M4,...."

    if my counter = #, the cell value is replaced by a value of M(#+1) as shown in the example above.

    the counter is from 1 to 999.

    How can I do this?

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,904

    Re: IF statement based on a counter

    Please Login or Register  to view this content.
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  3. #3
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,891

    Re: IF statement based on a counter

    Try this ...

    =INDEX($M$2:$M$1000,Counter)

+ 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. Calling different subroutines from a for/next loop based on a counter
    By arsonnenschein in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2016, 01:06 AM
  2. Loop Counter based on ID and TimeStamp Based on ID (Start/End)
    By ELeGault in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-12-2015, 04:44 AM
  3. Serial Counter based on unsorted Date
    By Rick_Hawk in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-20-2014, 08:43 AM
  4. Open a file based on a counter
    By jnh0 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-12-2013, 02:46 AM
  5. My IF statement does not recognise a counter
    By andreroux in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-07-2013, 06:40 AM
  6. Adding a Counter based on Criteria
    By EvilSean in forum Excel General
    Replies: 2
    Last Post: 02-15-2012, 11:34 AM
  7. Counter based on cell color
    By dolphin_m70 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-25-2009, 02:54 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