I'm working on a project to add up the width of rolls (WIDTH ORD) from a given parent roll identified by LENGTH. I only want to analyze parent rolls that have associated pattern numbers that are not integers. i.e. analyze rows with values 5.1, 6.2 but not 5, 6, 7 etc.
I added an excel file with some column values deleted for ease of reading.
Here is my full code
Option Explicit
Sub calc()
Dim LastRow As Integer
Dim sum As Integer
Dim x As Integer
Dim i As Integer
LastRow = ActiveSheet.UsedRange.Rows.Count
sum = 0
x = 1
'Sets column S as integer of column K
'Subtracts column S from column K and outputs in column T
'Allows me to distinguish data I want to delete
For i = 1 To LastRow
Cells(i, "S").Value = Int(Cells(i, "K"))
Cells(i, "T").Value = Cells(i, "K").Value - Cells(i, "S").Value
Next i
'Deletes rows that contain 0s in column T
'Deletes data I don't want to analyze
For i = 1 To LastRow
If Cells(i, "T").Value = 0 Then
Rows(i).Delete
End If
Next i
'Sums the values in column E for all rows that have the same value in column I
'Reports sums to column V
'Sums the width of each pattern roll and reports in column V
For i = 1 To LastRow
If Cells(i, "I") = Cells(i + 1, "I") Then
sum = sum + Cells(i, "E").Value
Else
Cells(x, "V").Value = sum + Cells(i, "E").Value
sum = 0
x = x + 1
End If
Next i
End Sub
I'm getting a mismatch type error at these parts
For i = 1 To LastRow
Cells(i, "S").Value = Int(Cells(i, "K"))
Cells(i, "T").Value = Cells(i, "K").Value - Cells(i, "S").Value
Next i
Else
Cells(x, "V").Value = sum + Cells(i, "E").Value
sum = 0
x = x + 1
End If
Could it be that the Cells.Value data type doesn't match the Int() data type?
In that case I don't know how to change either one of the data types.
Any help would be much appreciated!
Bookmarks