• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Macro to delete rows where positive & Negative values match and match (partial or full in narrative)|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Macro to delete rows where positive & Negative values match and match (partial or full in narrative)|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosMacro to delete rows where positive…
sp_PrintTopic sp_TopicIcon
Macro to delete rows where positive & Negative values match and match (partial or full in narrative)
Avatar
Howard Cohen
Member
Members
Level 0
Forum Posts: 48
Member Since:
December 8, 2016
sp_UserOfflineSmall Offline
1
May 27, 2020 - 11:20 am
sp_Permalink sp_Print sp_EditHistory

I have values in Col E and Narrative (Descriptions) in Col F

 

Where positive value/s or negative value matches negative value/s or positive value and they sum to zero , then the rows containing these values are to be deleted

 

I have written code to delete values where a positive and negative values matches but need it amended so that where the sum of positive and negative values are zero, then the rows are to be deleted. The alternative is also to look at the narrative and where the narrative matches either full or partial and the values sum to zero, to delete the rows

I have attached sample data showing where I am trying to achieve. The items in yellow are single values where the positive and negative values balance to zero and the items in blue is where several values match to zero

 

Your assistance in this regard is most appreciated

Not sure how to wrap code below

 Sub delete_values_that_Match()
Sheets("Imported data").Select
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

Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 412
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
2
May 28, 2020 - 7:11 am
sp_Permalink sp_Print

Hi Howard
How many rows of data will you have in the workbook on an ongoing basis? I think it will be easier to manually match off if the transaction volume is low or too much effort for excel to work out the potential matches.

The above code works well to match off single items but to get multiples to calculate will take a lot of effort and resources. I had to do something similar for my last company and I concluded that it was just too much work for excel to do.

In the end I had a database where I input an X in the far left column which validated the currency and the sum of the transactions to zero and then moved them to another sheet in the same workbook (with a linking reference). That way could always bring them back to the main reconciliation if the wrong items were matched off and I could also validate the sum of the matched items to zero for each currency on the matched sheet as an extra control.

This reconciliation only had about 150 transactions at anyone point so not hard to look through and match off.

Ultimately, I thought the controls on the spreadsheet in the importing, automated checking to the external system ledger and matching integrity was more important than 5 minutes of manual matching once per day.

Purfleet

Avatar
Howard Cohen
Member
Members
Level 0
Forum Posts: 48
Member Since:
December 8, 2016
sp_UserOfflineSmall Offline
3
May 28, 2020 - 11:45 am
sp_Permalink sp_Print

Thanks for your reply & input

 

The maximum number of rows would be 300

 

The maximum number of values that would equal sum to zero is 10. 90% of the values summing to zero would be 2 (one postive and one negative)

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: RAMEZ ATTAR, SALLY, Valentyn Kristioglo
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
Jessica Stewart: 205
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Bruce Tang Nian
Scot C
Othman AL MUTAIRI
Misael Gutierrez Sr.
Attif Ihsan
Kieran Fee
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Bhuwan Devkota
Forum Stats:
Groups: 3
Forums: 24
Topics: 6223
Posts: 27294

 

Member Stats:
Guest Posters: 49
Members: 31919
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.