Reputation: 21
I have a column (W:W) that shows the year something takes effect. I am writing simple VBA code to identify which rows of clients require "checking" because their effective date is greater than or equal to the year we are currently reviewing. I don't want to have to edit the VBA code each year so I've inserted an input box that I want to use later in the IF statement to flag the clients that need "checking". I keep getting "application-defined or object-defined error". Not sure what I'm doing wrong.
'Ask question for year of testing
Worksheets("Plan_Data").Activate
Dim TestingYear
TestingYear = Application.InputBox(prompt:="Which plan year end are you looking at (year only?)")
Range("C2").Select
ActiveCell.Formula = "=IF(W2>= & TestingYear &,""CHECK"","""")"
Upvotes: 1
Views: 42
Reputation: 2910
Try changing it to
ActiveCell.Formula = "=IF(W2>= " & TestingYear & ",""CHECK"","""")"
Upvotes: 2