View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Number of records for last 7 days

Hi,

Am Sat, 16 Jul 2016 19:47:18 -0000 (UTC) schrieb R D S:

I have a spreadsheet with a column of dates, I would like a textbox on a
form display the number of records in the last x days.


your dates in Sheet1 column A:

Private Sub UserForm_Initialize()
Dim x As Long, days As Long, period As Long

x = 12
period = Date - x
days = Application.CountIf(Sheets("Sheet1").Range("A:A"), "=" & period)
TextBox1.Text = days
End Sub


Regards
Claus B.
--
Windows10
Office 2016