Guys/Gals,
I am trying to have the below code place a formula in Cells(lRow, 3) that contains variables. However, every time i try this it shows a #Name ? error. I have searched on this forum for additional help, but i can't get their solutions to work in my code. Can someone please show me the light??! Below is my latest attempt.
I am trying to have the below code place a formula in Cells(lRow, 3) that contains variables. However, every time i try this it shows a #Name ? error. I have searched on this forum for additional help, but i can't get their solutions to work in my code. Can someone please show me the light??! Below is my latest attempt.
Code:
Dim lRow As Long
Dim ws As Worksheet
Dim wb As Workbook
Dim StatusCell As Range
Dim ElapsDays As Range
Dim CurDate As Range
Dim ProjDate As Range
Set ws = Worksheets(Cmbx_Project_Leaders.Value)
ws.Activate
lRow = Cells(Rows.Count, 2).End(xlUp).Row + 1
Set StatusCell = ws.Range("E" & lRow)
Set ElapsDays = ws.Range("C" & lRow)
Set CurDate = ws.Range("C3")
Set ProjDate = ws.Range("B" & lRow)
ws.Cells(lRow, 2).Value = txtb_Pj_srt_dt.Value
ws.Cells(lRow, 3).Formula = "=IF(OR(StatusCell.Address =""Completed"",StatusCell.address=""""), """",CurDate.address - ProjDate.address )"
ws.Cells(lRow, 4).Value = Txtb_Project.Value
ws.Cells(lRow, 5).Value = Cmbx_Status.Value
ws.Cells(lRow, 7).Value = Txtb_Note.Value
MsgBox ("Entry successfully added!")