Excelquestion35
Board Regular
- Joined
- Nov 29, 2021
- Messages
- 53
- Office Version
- 2016
- Platform
- 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"
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