Eric Penfold
Active Member
- Joined
- Nov 19, 2021
- Messages
- 431
- Office Version
- 365
- Platform
- Windows
- Mobile
Please could someone help with the Trim Function below.
It says wrong number of arguments?
It says wrong number of arguments?
VBA Code:
Sub Group_OrderNos()
Dim ws As Worksheet
Dim Rng As Range
Dim LRow As Long
Dim Row As Long
Dim Row_1 As Long
Dim Row_2 As Long
Dim ct As Long
Dim fr As Long
Dim i As Variant
Dim y As Variant
Set ws = ActiveSheet
Call Duplicate_Delete
If ws.Range("AA1") = "" Then
ws.Range("AA1") = 1
LRow = ws.Range("C2").End(xlDown).Row
Set Rng = ws.Range("L2:L" & LRow)
Rng.Clear
Rng.Value = "A"
If ws.Name <> "Summary" And ws.Name <> "Trend" And ws.Name <> "Supplier BO" And ws.Name <> "Dif Depot" _
And ws.Name <> "BO Trend WO" And ws.Name <> "BO Trend WO 2" And ws.Name <> "Different Depot" Then
On Error Resume Next
ws.Range("A1:H" & LRow).Sort Key1:=Range("C1"), Header:=xlYes, OrderCustom:=1, _
MatchCase:=False, Orientation:=xlTopToBottom
Application.ScreenUpdating = False
fr = 2
ct = 1
For Row = 2 To LRow
If Cells(Row, "C").Value = Cells(Row - 1, "C") Then
ct = ct + 1
End If
If Cells(Row, "C").Value <> Cells(Row + 1, "C") Then
If ct > 1 Then
On Error Resume Next
ws.Rows(fr & ":" & Row).Group
End If
ct = 1
fr = Row + 1
End If
Next Row
With ws
For Row = LRow To 2 Step -1
If (Trim$(Row, "C") = Trim$(Row - 1, "C")) And _
(Trim$(Row, "E") = Trim$(Row - 1, "E")) Then
Cells(Row - 1, "G") = Cells(Row, "G") + Cells(Row - 1, "G")
Cells(Row, "A").EntireRow.Delete
End If
End If
Next Row
MsgBox "OrderNos Group & Duplicate Codes Qty Group Complete!"
.Range("AA1") = ""
End With
End If
End If
Last edited by a moderator: