Hello everyone,
I'm new on the forum and I'm looking for help on this code.
The debug told me there a Type Mismatch mistake, but I can't find out what's wrong on my macro code.
Here below you can find my code, and the line with the problem is underlyned and in a bigger font.
Sub drag_all_formulas()
Dim UltimaRiga As Integer
Dim NumeroMesi As Integer
UltimaRiga = Range("G10000").End(xlUp).row
Application.ScreenUpdating = False
For i = 10 To UltimaRiga + 10000
If (Cells(i, 7) = "swap") And (Cells(i, 3) <> "*") And (Cells(i + 1, 3) <> "*") Then
NumeroMesi = Month(Cells(i, 16)) - Month(Cells(i, 15)) + (Year(Cells(i, 16)) - Year(Cells(i, 15))) * 12 + 1
Sheets("support").Select
Range("CA3:DU3").Select
Selection.Resize(NumeroMesi).Copy
Sheets("blotter oil 1").Select
Cells(i + 1, 1).Select
Selection.Insert Shift:=xlDown
Application.DisplayAlerts = True
Range(Cells(i + 1, 29), Cells(i + NumeroMesi, 41)).Select
Selection.ClearContents
Range(Cells(i + 1, 44), Cells(i + NumeroMesi, 44)).Select
Selection.ClearContents
Range(Cells(i + 1, 46), Cells(i + NumeroMesi, 46)).Select
Selection.ClearContents
ActiveCell.EntireRow.Select
Selection.Resize(NumeroMesi).Group
ActiveSheet.Outline.ShowLevels RowLevels:=1
End If
Next i
'formule per le sei/sette celle divalorizzazione
Sheets("support").Select
Range("CQ2:CW2").Select
Selection.Copy
Sheets("blotter oil 1").Select
For i = 10 To UltimaRiga + 10000
If ((Cells(i, 14) <> "") And (Cells(i, 18) = "") And (Cells(i, 21) = "")) Then
Cells(i, 17).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End If
Next i
SendKeys ("{ESC}")
Range("A10000").End(xlUp).Select
Application.ScreenUpdating = True
End Sub
I'm new on the forum and I'm looking for help on this code.
The debug told me there a Type Mismatch mistake, but I can't find out what's wrong on my macro code.
Here below you can find my code, and the line with the problem is underlyned and in a bigger font.
Sub drag_all_formulas()
Dim UltimaRiga As Integer
Dim NumeroMesi As Integer
UltimaRiga = Range("G10000").End(xlUp).row
Application.ScreenUpdating = False
For i = 10 To UltimaRiga + 10000
If (Cells(i, 7) = "swap") And (Cells(i, 3) <> "*") And (Cells(i + 1, 3) <> "*") Then
NumeroMesi = Month(Cells(i, 16)) - Month(Cells(i, 15)) + (Year(Cells(i, 16)) - Year(Cells(i, 15))) * 12 + 1
Sheets("support").Select
Range("CA3:DU3").Select
Selection.Resize(NumeroMesi).Copy
Sheets("blotter oil 1").Select
Cells(i + 1, 1).Select
Selection.Insert Shift:=xlDown
Application.DisplayAlerts = True
Range(Cells(i + 1, 29), Cells(i + NumeroMesi, 41)).Select
Selection.ClearContents
Range(Cells(i + 1, 44), Cells(i + NumeroMesi, 44)).Select
Selection.ClearContents
Range(Cells(i + 1, 46), Cells(i + NumeroMesi, 46)).Select
Selection.ClearContents
ActiveCell.EntireRow.Select
Selection.Resize(NumeroMesi).Group
ActiveSheet.Outline.ShowLevels RowLevels:=1
End If
Next i
'formule per le sei/sette celle divalorizzazione
Sheets("support").Select
Range("CQ2:CW2").Select
Selection.Copy
Sheets("blotter oil 1").Select
For i = 10 To UltimaRiga + 10000
If ((Cells(i, 14) <> "") And (Cells(i, 18) = "") And (Cells(i, 21) = "")) Then
Cells(i, 17).Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End If
Next i
SendKeys ("{ESC}")
Range("A10000").End(xlUp).Select
Application.ScreenUpdating = True
End Sub