Reputation: 11
I want to use an If()
inside an If()
statement. Is it possible without putting Else()
before.
My Code:
For i = 3 To 24
If i < 25 Then
sourcef = Sheets("Macro Control").Range("B" & i)
fname = "Z:\ISC-Product Costing\Manufacturing Controlling\03_BUDGETS\2019\Chocolate\OP'19\Reporting\Plant Submission\OP'19 Deck " & sourcef & ".xlsx"
Workbooks.Open fname, UpdateLinks:=0
Set wC3 = ActiveWorkbook
Set wC1 = wC3.Sheets("Conversion P&L")
Set wC2 = ThisWorkbook.Sheets(sourcef)
Sheets("Conversion P&L").Select
ThisWorkbook.Activate
Sheets(sourcef).Select
Call CompareColumns
Range("A1").Select
ActiveCell.FormulaR1C1 = "EUR"
Range("B2").Select
("some more Code")
wC3.Activate
ActiveWindow.Close savechanges:=False
Else
End If
Next i
(some more code)
End Sub
I want to add one more If
after Call CompareColumns
. How to do it?
Call CompareColumns
is another macro in which value for "same" will be defined as True or False. I want to add If Same = True then
"Code continues" Else
go to wc3. Activate
.
Upvotes: 0
Views: 1322
Reputation: 964
If you need more if you can use select case: i.e.
Select Case yourInput
Case Is <= 25
'your code
Case Is >= 70
'your code
Case Else
'your code
End Select
Upvotes: 0
Reputation: 3389
You can use as much 'If' as you want. And you also dont need to use the else case.
If .... Then
If .... Then
....
Else
....
End If
End If
In your case:
If i < 25 Then
Code...
If i < 25 Then
Call CompareColumns
Rest of code....
Else
wc3.Activate
Rest of code....
End If
End If
Upvotes: 1