ok so... I have a worksheet that I am trying to get to auto populate... I tried formulas and I am sure I need code for this. I am new to code so please let me know if anyone has an awnser, code, and how to impliment it in the sheet...

basically... if D17 is equal to or greater than 18 then, B31=B7,G31=G7, B33=B9, E33=E9, G33=G9, I33=I9, B35=B11, E35=E11, H35=H11, B37=B13, G37=G13, B38=B14, E38=E14, H38=H14, B39=D15, F39=B17, I39=B18. If it is less than 18 then leave B31, G31, B33, E33, G33, I33, B35, E35, H35, B37, G37, B38, E38, H38, B39, F39, I39 blank for new data to be populated.

I was given this code: but I get an error - on the line "If Intersect(Target, Range("D17")) Then"

- the error states

Run-time error '91':
object variable or with variable not set


Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False

If Intersect(Target, Range("D17")) Then
If Range("D17") >= 18 Then
Range("B31").Formula = "=B7"
Range("G31").Formula = "=G7"

'OR IF YOU WANT VALUES INSTEAD

'Range("B31").Value = Range("B7").Value
'Range("G31").Value = Range("G7").Value
End If

Else
Range("B31").Clear
Range("G31").Clear

End If

Application.EnableEvents = True

End Sub


Can anyone help?