Hi guys, I hope you can help me with a code I'm trying unsuccessfully to make work.
At a certain point in my code, it is necessary to write a formula in a cell that presents an IF statement of the type:
=IF(JANUARY!$E2=TRUE;"Correct";"")
So basically it checks if Cell E2 in sheet JANUARY equals TRUE. If it does, it writes "Correct" and if false it writes nothing. Without VBA (so simply typing it) it is working fine.
Now I want the month in that formula to be a variable, as well as the Row number (the column will always be the same).
I created a variable called MonthName and another one called UnitRow, they are both working (MonthName currently is FEBRUARY and UnitRow = 4) but the formula as I wrote returns an error in VBA.
Here's how it is now:
ActiveCell.Formula = "=IIF(" & MonthName & "!$E" & UnitRow & "=TRUE;""Correct"";"""")"
Could someone help me with this?
At a certain point in my code, it is necessary to write a formula in a cell that presents an IF statement of the type:
=IF(JANUARY!$E2=TRUE;"Correct";"")
So basically it checks if Cell E2 in sheet JANUARY equals TRUE. If it does, it writes "Correct" and if false it writes nothing. Without VBA (so simply typing it) it is working fine.
Now I want the month in that formula to be a variable, as well as the Row number (the column will always be the same).
I created a variable called MonthName and another one called UnitRow, they are both working (MonthName currently is FEBRUARY and UnitRow = 4) but the formula as I wrote returns an error in VBA.
Here's how it is now:
ActiveCell.Formula = "=IIF(" & MonthName & "!$E" & UnitRow & "=TRUE;""Correct"";"""")"
Could someone help me with this?