+ Reply to Thread
Results 1 to 21 of 21

Macro to Match Items in Col C

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-12-2018
    Location
    South Africa
    MS-Off Ver
    Office 2024
    Posts
    2,873

    Re: Macro to Match Items in Col C

    Hi Marc


    Thanks for getting back to me and fully understand your predicament


    I am attaching another workbook with references, which I hope you will be able to assist



    1) Where there is a value in Col C with say a positive value eg 2150 and there is a single value that is negative -2150 then the rows containing these values are to be deleted (I have highlighted all the items in yellow where the positive value and negative values equal to zero). I have also put numbers next to each of the yellow items that match off

    2) Where there are several debit balances (have highlighted in different colours) with the same reference then these must be matched to credit balances and vice versa (have indicated the matching with numbers in Col I so you can see how these match off)


    3) There may be values where the sum of the debits and credits balance to zero, but they can have mixed references




    With regard to point # 1 above, I have written code which matches the Debit & credit values for a single item, but point # 2 & 3 is above is too complicated for me to write the code



     Sub delete_same_amount()
    Dim lRow&, iRow&, c As Range
    lRow = Cells(Rows.Count, 5).End(xlUp).Row
    For iRow = lRow To 2 Step -1
        If Cells(iRow, 5) > 0 Then
            With Columns(5)
                Set c = .Find(Cells(iRow, 5).Value * -1, LookIn:=xlValues, lookat:=xlWhole)
                    If Not c Is Nothing Then
                        Rows(iRow).Delete shift:=xlUp
                        c.EntireRow.Delete shift:=xlUp
                    End If
            End With
        End If
    Next iRow
    End Sub
    Last edited by Howardc1001; 04-30-2020 at 11:02 AM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Question Re: Macro to Match Items in Col C


    Quote Originally Posted by Howardc1001 View Post
    I am attaching another workbook with references
    So where is it ? Not in your last post …

+ 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] Macro to delete certain items then count remaining items #2
    By elgato74 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-21-2019, 02:26 PM
  2. [SOLVED] Macro to delete certain items then count remaining items
    By elgato74 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-14-2019, 03:20 PM
  3. Replies: 2
    Last Post: 11-17-2016, 06:37 AM
  4. [SOLVED] Need to count items in column that match multiple data items
    By bclucas55 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-27-2014, 10:03 AM
  5. macro to filter all items in Autofilter except 2+ items
    By DanRiverBrew in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-09-2013, 09:15 PM
  6. [SOLVED] One to many items match
    By Pavan_Jack in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-30-2012, 01:16 PM
  7. [SOLVED] Match Items
    By vharjani3 in forum Excel General
    Replies: 17
    Last Post: 06-04-2012, 09:14 AM

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