Q:

Inputting a random date into a cell - Excel VBA

Doing some research on this and i found there are ways to generate random dates in a range using functions within the excel spreadsheet like so:
 =DATE(2010, 1, 1)+LARGE(IF(WEEKDAY(DATE(2010, 1, 1)+ROW($1:$365)-1, 2)<6, ROW($1:$365)-1, ""), RANDBETWEEN(1, SUM(--(WEEKDAY(DATE(2010, 1, 1)+ROW($1:$365)-1, 2)<6))))

is there a way I can do this and insert it straight into a cell like
Cells(i, "F").Value = //Random Date//

A:

The VBA way:
Sub RandomDates()
    Dim startDate As Date, endDate As Date, randomDate As Date

    startDate = "1/1/1990"
    endDate = "1/1/2012"

    Cells(i, "f") = WorksheetFunction.RandBetween(startDate, endDate)
    Cells(i, "f").NumberFormat = "d/m/yyyy"
End Sub

