Hi guys, need your expertise here, my current code asks the user to specify the dates for fDateA to fDateC in the inputbox, the problem is the custom dates might not be available, can anyone helpe me edit the code to loop the inputbox to ask back the user to reenter another date, when the date is unavailable, and loop the error message until a valid date has been entered.

For example lets say user enters in inputbox for fdateA "9/9/2012", but data for date "9/9/2012" doesnt exists, so the code would prompt an error msgbox and restart the inputbox for user to reenter another choosen date, and loop until date choosen is valid.

The same goes for fdateB and fdateC. Please help out.


Function CustomDateData()

Dim theMsg As String
Dim fdateA As String
Dim fdateB As String
Dim fdateC As String

theMsg = "Data has gaps in the extraction dates, user's have to choose custom dates to extract the data, please input the three dates in the next 3 input boxes"

MsgBox theMsg

Application.Calculation = xlCalculationManual

ClearItems 'Clears pivotitems in pivottable

fdateA = InputBox(Prompt:="Enter the current report date, valid format is mm/dd/yyyy", Title:="ENTER CUSTOM DATE", Default:="m/d/2012")
fdateB = InputBox(Prompt:="Enter closest previous date available from current report date, valid format is mm/dd/yyyy", Title:="ENTER CUSTOM DATE", Default:="m/d/2012")
fdateC = InputBox(Prompt:="Enter date around one week before current date, valid format is mm/dd/yyyy", Title:="ENTER CUSTOM DATE", Default:="m/d/2012")

pt.PivotFields("Date").PivotItems("(blank)").Visible = False

pt.PivotFields("Date").PivotItems(fdateA).Visible = True
pt.PivotFields("Date").PivotItems(fdateB).Visible = True
pt.PivotFields("Date").PivotItems(fdateC).Visible = True


Application.Calculation = xlCalculationAutomatic

End Function
Thanks in advance.