rsutton1981
New Member
- Joined
- Mar 9, 2016
- Messages
- 47
- Office Version
- 365
- Platform
- Windows
Hi,
Our accounting software exports all values as positive even if it is a credit.
I have tried and failed to make some VBA to do this by it fails
The target is "SC" in Column B from row 15 onwards.
if "SC" is noted then the values in K, L and O should be changed to negative.
using some other VBA code previously used I have got this but it fails
Please help
Our accounting software exports all values as positive even if it is a credit.
I have tried and failed to make some VBA to do this by it fails
The target is "SC" in Column B from row 15 onwards.
if "SC" is noted then the values in K, L and O should be changed to negative.
using some other VBA code previously used I have got this but it fails
VBA Code:
Sub reverse_SC()
' make value negative with MyTarget
Const MyTarget = "SC" ' <-- change to suit
Dim Rng As Range
Dim I As Long, j As Long
' Calc last row number
'j = Cells.SpecialCells(xlCellTypeLastCell).Row 'can be:
j = Range("B" & Rows.Count).End(xlUp).Row
' Collect rows with MyTarget
For I = j To 1 Step -1
If WorksheetFunction.CountIf(Rows(I), MyTarget) > 0 Then
If Rng Is Nothing Then
Set Rng = Rows(I)
Else
Set Rng = Union(Rng, Rows(I))
End If
End If
Next
' Change cell with MyTarget
If Not Rng Is Nothing Then Columns ("k") xValue *-1
' Update UsedRange
With ActiveSheet.UsedRange: End With
End Sub
Please help