TylerCross
New Member
- Joined
- Jan 5, 2021
- Messages
- 7
- Office Version
- 2010
- Platform
- Windows
Hello Everyone.
I am current using a code that consolidates rows. In my code I have the option in one of the columns to add the sum of the rows. I am wanting to change the code to just code the number of row instead of adding the sum of the numbers. I am having a trouble time trying to figure out a way to do this. The part of the code that is highlighted red is where the sum is occurring.
Any help is greatly appreciated.
Have a great day!
I am current using a code that consolidates rows. In my code I have the option in one of the columns to add the sum of the rows. I am wanting to change the code to just code the number of row instead of adding the sum of the numbers. I am having a trouble time trying to figure out a way to do this. The part of the code that is highlighted red is where the sum is occurring.
Any help is greatly appreciated.
Have a great day!
Rich (BB code):
Sub mergeCategoryValues2()
Dim lngRow As Long
With Sheet2
Dim columnToMatch As Integer: columnToMatch = 1
Dim columnToConcatenate As Variant: columnToConcatenate = 22
Dim columnToSum As Integer: columnToSum = 2
lngRow = .Cells(65536, columnToMatch).End(xlUp).Row
.Cells(columnToMatch).CurrentRegion.Sort key1:=.Cells(columnToMatch), Header:=xlYes
Do
If .Cells(lngRow, columnToMatch) = .Cells(lngRow - 1, columnToMatch) Then
.Cells(lngRow - 1, columnToConcatenate) = .Cells(lngRow - 1, columnToConcatenate) & "; " & .Cells(lngRow, columnToConcatenate)
.Cells(lngRow - 1, columnToSum) = .Cells(lngRow - 1, columnToSum) + .Cells(lngRow, columnToSum)
.Rows(lngRow).Delete
End If
lngRow = lngRow - 1
Loop Until lngRow = 1
End With
MsgBox (" Macro Complete! ")
End Sub