+ Reply to Thread
Results 1 to 4 of 4

Check if a value's position is before the position of another value in a range

  1. #1
    Registered User
    Join Date
    02-10-2014
    Location
    Schaumburg, IL
    MS-Off Ver
    Excel 2007
    Posts
    24

    Check if a value's position is before the position of another value in a range

    Hi,

    I'm looking for some guidance on determining if the position of value "A" in a range is before the position of value "B" in the same range. Basically, I have two columns. Column A is a list of numbers from 1 to 50 in order. Column B contains various positive and negative dollar amounts. I want to be able to run a macro that will return the position of value "A" only if it is before the position of value "B".

    Here's a fuller explanation of what I am trying to do. I have 40 worksheets, each having two columns. Each worksheet represents 1 Blackjack session. Column A has numbers 1 to 50 in order. These represent Blackjack hands. Column B has a corresponding total dollar amount (positive or negative) for each hand in column A. This is the amount up or down at each hand. The macro will contain two variables that are dollar amounts: "up" and "down". Let's say "up" = $100 and "down' = -$150. As an example, when the macro is run, it will look through Column B to find where $100 occurs before -$150 occurs on each of the 40 worksheets. It will then return the total count of the number of worksheets where this is true.

    For right now, I just need to figure out how to find if one value occurs before another value in a range.

    Let me know if more information or clarification is needed.

    Thanks in advance

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Check if a value's position is before the position of another value in a range

    How the output should be?
    In 41st sheet, or via msgbox?
    A sample workbook would help a lot.
    Quang PT

  3. #3
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Check if a value's position is before the position of another value in a range

    Here's one way (on the proviso I've understood the question!)
    Please Login or Register  to view this content.
    BSB

  4. #4
    Registered User
    Join Date
    02-10-2014
    Location
    Schaumburg, IL
    MS-Off Ver
    Excel 2007
    Posts
    24

    [Solved] Check if a value's position is before the position of another value in a range

    BadlySpelledBuoy, thanks for the reply. Your answer works. However, I ended-up using a different approach. Basically, my code checks each cell in the range until it finds one of the parameters (i.e. either 100 or -150). If one is found, then the code does something, then goes to the next worksheet and checks the cells in the range in that worksheet. If none are found, then the code goes to the next worksheet and checks the cells in the range in that worksheet. If anyone is interested in the code and sample workbook, let me know and I'll upload it. Thanks again for your help.
    Last edited by gdaniels; 01-07-2022 at 12:26 PM. Reason: typo

+ 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. Race Position Tracker - Calc Ahead and Behind Relative to Own Position
    By JLI127 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-10-2021, 09:39 PM
  2. separate the numbers from the 4th position to the 12th position.
    By jorel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2020, 04:58 PM
  3. Replies: 1
    Last Post: 06-21-2019, 06:18 AM
  4. [SOLVED] To check the position of a word in a range of cells & to get difference between the cells
    By KARTHICKNAIDU in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-03-2016, 09:07 AM
  5. Dynamic userform position based on widow position
    By Manish84 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-16-2015, 07:47 AM
  6. Replies: 1
    Last Post: 06-22-2012, 08:59 PM
  7. [SOLVED] Position of CellCursor on Screen (absolute position)
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-22-2005, 10:25 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