Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 10-28-2018, 04:31 AM
p45cal's Avatar
p45cal p45cal is offline Need Help with Current Macro Windows 10 Need Help with Current Macro Office 2016
Expert
 
Join Date: Apr 2014
Posts: 948
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

I note that every account name you want to make negative contains either the word Return or Pilferage, so instead of having a list of full account names (which have to be exactly the same as on your sheet) you could look for instances of (say) return and/or pilfer in the account names instead.
In the code below, there's a line:
myWords = Array("returns", "pilfer")
to which you can add other words to find in account names you want to make negative.
Code:
Sub test()
Dim Cell As Range, ws As Worksheet, myWords, cll As Range
myWords = Array("returns", "pilfer")
For Each ws In Worksheets(Array("130R", "135R", "140R"))
  For Each cll In ws.Range("B4:B45").Cells
  If UBound(Filter(Application.IsErr(Application.Search(myWords, cll.Value)), "True", False)) > -1 Then
      For Each Cell In cll.Offset(, 3).Resize(, 12).Cells
        If Cell.Value > 0 Then Cell.Value = Cell.Value * -1
      Next Cell
    End If
  Next cll
Next ws
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with Current Macro Macro to auto-save pdf using text on page + current date hysterical.useless Word VBA 12 02-05-2018 02:17 PM
Need Help with Current Macro macro, data import from the ONLY text file in current folder ue418 Excel Programming 5 10-28-2017 12:52 PM
a macro that can copy data from copy.xls to our current excel macro.xls based on criteria: udhaya Excel Programming 1 11-12-2015 10:12 AM
A macro that moves the current paragraph up or down? New Daddy Word VBA 2 04-13-2014 02:25 PM
Need Help with Current Macro Macro for moving one cell down from current position Johnny thunder Word VBA 3 04-07-2011 04:44 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft