I have the following code that is causing a
capacity overflow error type 6
due to the code between '------------------------------------'. I will appreciate your help :)!
I was not able to solve it with other discussion.
Sub Calculate_Mix()
Dim rngUsernameHeader As Range
Dim rngHeaders As Range
Dim rngAddress As Range
Dim rng_R1 As Range
Dim rng_delisted As Range
Dim ws As Worksheet
Dim value As Long
Set ws = ThisWorkbook.Sheets("Sheet1")
Set rngHeaders = Range("1:1") 'Looks in entire first row.
Set rngUsernameHeader = rngHeaders.Find(what:="VAl MAT'Mar18", After:=Cells(1, 1))
rngUsernameHeader.Offset(0, 1).EntireColumn.Insert
rngUsernameHeader.Offset(0, 1).value = "Delisted"
rngUsernameHeader.Offset(0, 2).EntireColumn.Insert
rngUsernameHeader.Offset(0, 2).value = "New Launches"
rngUsernameHeader.Offset(0, 3).EntireColumn.Insert
rngUsernameHeader.Offset(0, 3).value = "Price_17"
rngUsernameHeader.Offset(0, 4).EntireColumn.Insert
rngUsernameHeader.Offset(0, 4).value = "Price_18"
For Each Cel In Range("F2", Range("F2").End(xlDown))
If Cel > 0 And Cel.Offset(0, 1) = 0 Then
Cel.Offset(0, 2).value = Cel.value
Else: Cel.Offset(0, 2).value = 0
End If
If Cel = 0 And Cel.Offset(0, 1) > 0 Then
Cel.Offset(0, 3).value = Cel.Offset(0, 1).value
Else: Cel.Offset(0, 3).value = 0
End If
Next Cel
'------------------------------------'
For Each Cel In Range("H2", Range("H2").End(xlDown))
If Cel = 0 And Cel.Offset(0, 1) = 0 Then
value = Cel.Offset(0, -2).value / Cel.Offset(0, -4).value
Cel.Offset(0, 2).value = value
Else: Cel.Offset(0, 2).value = 0
End If
Next Cel
'------------------------------------'
End Sub
Longvariable type?