I can't put an If/And formula into a cell because it has a validation list connected to it. So I need to figure out how to put the formula into a VBA code.
This is what I have come up with but it's not working...
So what I need is if F16= date....
If date is between I11 to J11 then cell G11 will be copied into cells F17,F19,& F21
If date is between I12 to J12 then cell G12 will be copied into cells F17,F19, & F21
If date is between M10 to N10 then cell K10 will be copied into cells F17,F19, & F21
If date is between M11 to N11 then cell K11 will be copied into cells F17,F19, & F21
If date is between M12 to N12 then cell K12 will be copied into cells F17,F19, & F21
If date is blank then F17,F19 & F21 will be left blank.
This is what I have come up with but it's not working...
Code:
Private Function FirstProcess(ByVal Target As Range)
If Range("F16").Value = Range("I11 to J11").Value Then
Range("F17,F19,F21").Value = Range("G11").Value
ElseIf Range("F16").Value = Range("I12 to J12").Value Then
Range("F17,F19,F21").Value = Range("G12").Value
ElseIf Range("F16").Value = Range("M10 to N10").Value Then
Range("F17,F19,F21").Value = Range("K10").Value
ElseIf Range("F16").Value = Range("M11 to N11").Value Then
Range("F17,F19,F21").Value = Range("K11").Value
ElseIf Range("F16").Value = Range("M12 to N12").Value Then
Range("F17,F19,F21").Value = Range("K12").Value
Else
Range("F17,F19,F21").Value = 0
End If
End Function
So what I need is if F16= date....
If date is between I11 to J11 then cell G11 will be copied into cells F17,F19,& F21
If date is between I12 to J12 then cell G12 will be copied into cells F17,F19, & F21
If date is between M10 to N10 then cell K10 will be copied into cells F17,F19, & F21
If date is between M11 to N11 then cell K11 will be copied into cells F17,F19, & F21
If date is between M12 to N12 then cell K12 will be copied into cells F17,F19, & F21
If date is blank then F17,F19 & F21 will be left blank.