+ Reply to Thread
Results 1 to 4 of 4

Macro to delete selection of data if cell is certain value

  1. #1
    Registered User
    Join Date
    02-28-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    16

    Macro to delete selection of data if cell is certain value

    I have a list of product transactions on sheet 1 (over 17000) listed by product code.

    On sheet two i have a VLookup formula that looks up the value of the product code i enter into a cell, and returns the first transaction type for that product code. (Either 'AI' for adjustment in, or 'GO' for goods out).

    I need the number of each product sold before we did a stock take. If the first transaction was a AI it means that it was stock taken before we sold any, if the first transaction was GO it means we sold some before it had been stock taken, and needs to be added back into the system.

    So if the first reading on a product code was an AI, all transactions for that code can be deleted, if the first transaction was a GO I need to count how many we sold before the AI, and input back into stock.

    Is there any way i can enter a product code, and if the first reading (as shown by the Vlookup) is equal to AI then all records of that product code are deleted?


    There are over 3000 products and I really dont want to have to go through each one manually. Maybe I'm going to have to, just thought i'd give it a go here first before I did.


    All help would be greatly appreciated.

    Rogerj99
    Attached Files Attached Files

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro to delete selection of data if cell is certain value

    Cross posted here:http://www.mrexcel.com/forum/showthread.php?p=3113774
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Macro to delete selection of data if cell is certain value

    Could you please add headers to your file?

    but to be clear, what you are looking to do is count all of the quantity for products that start with a GO line, up to the first AI line?
    If you liked my solution, please click on the Star -- to add to my reputation

    If your issue as been resolved, please clearly state so and mark the thread as [SOLVED] using the thread tools just above the first post.

  4. #4
    Forum Expert DGagnon's Avatar
    Join Date
    02-23-2012
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1,645

    Re: Macro to delete selection of data if cell is certain value

    based on what i think you are trying to do, try this formula

    =SUMPRODUCT((countings!A$1:A$20000=B2)*(countings!F$1:F$20000)*(ROW(countings!F$1:F$20000)<MIN(IF(countings!A$1:A$20000=B2,IF(countings!B$1:B$20000="AI",ROW(countings!A$1:A$20000),20000)))))

    where Col B is yoru Product Code in the same sheet as this formula.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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