If statement in an if statement

Excelquestion35

Board Regular
Joined
Nov 29, 2021
Messages
53
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

Currently I am struggling to get an IF statement working inside an IF statement. It concerns the last part of the code below. I would like to check whether a value inside a cell is equal to "Verwijderen". Then it has to insert 'No' in the rule below in a specific column, if that is not the case it should do nothing and just continue/finish.
The code runs properly when it is indeed that the case that value is equal to "Verwijderen". However, when it is not true, it will not execute anything of the rest of the code (above).

Any idea how I can still execute the other code if the value is not equal to "Verwijderen"

Excel Formula:
Sub Test()
inarr = ActiveSheet.Range("$B$1:$AS$66") ' load all the data into a variant array NOTE starting from row1
manager = Sheets("FLM-change").Range("C18")
site = Sheets("FLM-change").Range("C17")
newflm = Sheets("FLM-change").Range("C13")
wlmuserid = Sheets("FLM-change").Range("C10")
kronosid = Sheets("FLM-change").Range("C11")
mail = Sheets("FLM-change").Range("C12")
verandering = Sheets("FLM-change").Range("C19")

For i = 3 To 66   ' start loop at row 3
   If inarr(i, 2) = manager And inarr(i, 1) = site Then ' we have found the row
    Range(Cells(i, 2), Cells(i, 45)).Select ' do whatewver you need to do on this row
    Selection.Copy
    Selection.Insert Shift:=xlDown
    ActiveCell.Offset(0, 1).Range("A1").Select
    ActiveCell.FormulaR1C1 = newflm
    
 
    ActiveCell.Offset(0, 1).Range("A1").Select
    ActiveCell.Value = "=Today()"
    ActiveCell.Offset(0, 0).Range("A1").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    
    
    ActiveCell.Offset(0, 1).Range("A1").Select
    ActiveCell.FormulaR1C1 = manager
    
    ActiveCell.Offset(0, 1).Range("A1").Select
    ActiveCell.FormulaR1C1 = kronosid
    
    ActiveCell.Offset(0, 3).Range("A1").Select
    ActiveCell.FormulaR1C1 = mail
    
    ActiveCell.Offset(0, 4).Range("A1").Select
    ActiveCell.FormulaR1C1 = wlmuserid
    
    ActiveCell.Offset(0, 2).Range("A1").Select
    ActiveCell.FormulaR1C1 = mail
    
        If verandering = "Verwijderen" Then ActiveCell.Offset(1, -11).Range("A1").Select
        ActiveCell.FormulaR1C1 = "No"
        ElseIf verandering = "Ongewijzigd" Then
        
    Exit For
        
   End If
Next i
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
What happens if you remove these two lines
VBA Code:
        ElseIf verandering = "Ongewijzigd" Then
        
    Exit For
 
Upvote 0
Solution
Hi Fluff,

Thank you for your reply. I tried that in the beginning but then it didn't work, somehow when I tried it again it works properly. Thank you for your help!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top