Tuesday, 15 April 2014

excel - Get all dates between 2 dates in vba -


I'm a newbie in VBA and for example I will call for 2 dates between all the dates in VBA I am doing, 2015/01/01 02-01: parameters 2015/01/01 and 15-01-2015, and I will find in all dates possibles, ie return an array with Function-2015 with 2015/01/01 ..... 15-01-2015 I have not got answers on the forums, thanks in advance for your help so much.

Text after "div class =" itemprop = "text">

You just change dated long and make loop (+1) and between all 2 dates Dated Mill (can be changed to date again)

  Sub-calling () Dim test test = getDates (# 1/25/2015 #, # 2/5/2015 # ) End Sub function getDates (Date as ByVal StartDate date, as Date byVal EndDate) Version varied as varDates () Date dim lngDateCounter Long ReDim as varDates (1 to CLng (EndDate) - CLNG (StartDate) LngDateCounter = LBound (varDates) VarDates VarDates (lngDateCounter) = CDate (StartDate) StartDate = CDate (StartDate) + 1) Next lngDateCounter getDates = varDates ClearMemory: If IsArray (varDates) then erase varDates LngDateCounter = Empty End Function  

No comments:

Post a Comment