Hi, I am trying to make a macro that groups up rows and sums the amount of items that they have on a column, I made it so it works but after a few rows it just crashes and displays Error 13: Type mismatch.
When I open the code it highlights this line
The code is this one:
If it's necessary I can send the excel file too.
When I open the code it highlights this line
stringb = Cells(cont2, 7)
The code is this one:
I can't come up with a solution and I came here to see if someone could help me, thanks in advance.Sub Juntarfilas()
Dim Av1 As Double
Dim cont As Long
Dim cont2 As Long
Dim numcol As Integer
Dim comp1 As Integer
Dim check As String
Dim string1 As String
Dim string2 As String
Dim stringa As String
Dim stringb As String
Dim Rango As Variant
Sheets("RESULTADO").Select
numcol = Range("E2").Column
cont = 2
cont2 = 3If IsEmpty(Range("E2").Value) = True Then
check = 0Else
check = 1End If
While (check = 1)string1 = Cells(cont, 5)
string2 = Cells(cont2, 5)
stringa = Cells(cont, 7)
stringb = Cells(cont2, 7)
comp1 = StrComp(string1, string2)
If (comp1 = "0") Then
Rango = Range(Cells(cont, 7), Cells(cont2, 7))
Av1 = Application.WorksheetFunction.Sum(Rango)
Cells(cont, 7) = Av1
cont = cont
cont2 = cont2
Rows(cont2).EntireRow.DeleteElse
cont = cont + 1
cont2 = cont2 + 1End If
If IsEmpty(string1) = True Then
check = 0Else
check = 1End IfWendEnd Sub
If it's necessary I can send the excel file too.