Hi All,
im having problems using VBA to insert an IF formula,
im running a code all using relitive references and i'd like to every time the macro runs to add a new action it adds the IF formula so i dont need to drag it down all the time. I need it to insert a word depending on if an action is overdue, pending insert that word.
This is the IF formula used in excel
"=IF(ISBLANK(L3),IF(K3<TODAY(), ""Overdue"", IF((K3-10)<TODAY(), ""Imminent"",IF((K3-11)>=TODAY(),""Pending""))),""Complete"")"
But i need it to change K3 depending on which row is active if thats makes sense?
so how do i get VBA to add a formula or drag it down like you would normally to change the cells to K3, K4, K5 etc?
any help would be great, thanks! 
My whole sheet is designed to insert actions using a userform, whole code below if thats helpful to see what im trying to do:
Private Sub CommandButton1_Click()
If TextBox1.Value = "" Then
MsgBox "Please Fill in The Action!"
Else
If Forum.Value = "" Then
MsgBox "Please Select a Forum"
Else
If Area.Value = "" Then
MsgBox "Please Select a Forum"
Else
If Owner.Value = "" Then
MsgBox "Please Enter an Action Owner"
Else
If Category.Value = "" Then
MsgBox "Please Enter an Action Category"
Else
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Consolidated Action Tracker")
Dim FirstBlankCell As Range
ActiveSheet.Unprotect "pass"
'Add Action Number
Set FirstBlankCell = Range("B" & Rows.Count).End(xlUp).Offset(1, 0)
FirstBlankCell.Activate
ActiveCell = UserForm1.TextBox2.Value
'Add Forum
ActiveCell.Offset(0, 1) = UserForm1.Forum.Value
'Add Area
ActiveCell.Offset(0, 2) = UserForm1.Area.Value
'Add Owner
ActiveCell.Offset(0, 3) = UserForm1.Owner.Value
'Add Agreed?
If OptionButton1.Value = True Then
ActiveCell.Offset(0, 4) = "Yes"
Else
ActiveCell.Offset(0, 4) = "No"
End If
'Add Action
ActiveCell.Offset(0, 5) = UserForm1.TextBox1.Value
'Add Category
ActiveCell.Offset(0, 6) = UserForm1.Category.Value
'Add Reference
ActiveCell.Offset(0, 7) = UserForm1.Reference.Value
'Add Due Date
ActiveCell.Offset(0, 9) = UserForm1.DTPicker1.Value
'Vlookup for the managers name from vlookupsheet users database and enter managers name
ActiveCell.Offset(0, 12) = Application.WorksheetFunction.VLookup(Range("E" & ActiveCell.Row), Range("Users"), 2, False)
'Change sheet and add 1 to the action number count
Sheets("Other_Databases").Activate
Range("Action").Value = Range("Action").Value + 1
'Move back to the main action tracker sheet
Sheets("Consolidated Action Tracker").Activate
ActiveSheet.Protect "pass"
'Unload the userform
Unload Me
End If
End If
End If
End If
End If
End Sub
Bookmarks