Elysium4Eternity
New Member
- Joined
- May 7, 2018
- Messages
- 12
Code:
Sub Financiël_Gevel_€_M²_JAAR()
Dim i As Long
Dim j As Long
Dim k As Long
Dim l As Long
For i = 3 To 4001 Step 4
If Range("F" & i).Value = "Elektriciteit" Then
For j = 3 To 4001 Step 4
Range("L" & i).FormulaR1C1 = "=r[-1]c*r5c34"
Next j
ElseIf Range("F" & i).Value = "Aardgas" Then
For k = 3 To 4001 Step 4
Range("L" & i).FormulaR1C1 = "=r[-1]c*r7c34"
Else
For l = 3 To 4001 Step 4
Range("L" & i).FormulaR1C1 = "=r[-1]c*r9c34"
Next l
End If
Next i
End Sub
In my sheet F3 is a cell in wich you can choose one of the following options: Elektriciteit, Aaardgas and Stookolie. But I want my code to run automatically when I switch between one of those options. I know how to do this but the problem is that the method I know of will run the macro for the entire sheet. And since I have 4000 lines it will take a long time for excel to process this. Is there a way to run the macro individually for a few rows instead of the entire sheet?