Shenzar
New Member
- Joined
- Jan 8, 2021
- Messages
- 5
- Office Version
- 2019
- Platform
- Mobile
- Web
Hello,
I have been looking for a solution for a few days
In my code below
The if and the else are executed at the same time in the same cell, both conditions are checked at the same time instead of:
if the answer is equal to 1 then the answer is equal to 2 else the answer is equal to 3
If I delete else the code works perfectly
I do not understand
I have been looking for a solution for a few days
In my code below
VBA Code:
Sub Mod2()
Const Lignes% = 110 Dim Sh1 As Worksheet, Sh2 As Worksheet, I As Long
Set Sh1 = Worksheets("Calcul"): Set Sh2 = Worksheets("Calc")
For I = 2 To Lignes
If Sh2.Range("A1") = "YOY" then
If Sh1.Cells(I, 1) = "P-YOY-01" Then Sh2.Cells(11, 10) = Sh1.Cells(I, 8) Else Sh2.Cells(11, 10) = "NA"
end If
Next I
End Sub
The if and the else are executed at the same time in the same cell, both conditions are checked at the same time instead of:
if the answer is equal to 1 then the answer is equal to 2 else the answer is equal to 3
If I delete else the code works perfectly
I do not understand