I want to search for all Dates belonging to a month. The Month will be selected by the user. I am unable to search all dates, I only get the last date which is entered. I am using find function and unable to provide the specific conditions.
mois = InputBox("Choisissez le mois (Entrer la valeur Numérique)!!! (1 pour Janvier, 2 pour Fév .... )", "Titre")
If mois > 0 & mois < 12 Then
' Search for matching date
Set cellsearch = Range("G1:G" & NbrLinesDate).Find(What:=mois_chercher)
If cellsearch Is Nothing Then
If mois < 0 Then
ElseIf mois > 12 Then
End If
Else
ligne = cellsearch.Row
Date_to_search = Range("G" & ligne).Value
End If
End If
MsgBox Date_to_search '' Checkpoint_1
JourTest = Day(Date_to_search)
JourTest = Trim(JourTest)
MsgBox JourTest '' Checkpoint_2
Mois is the variable, that stores user provided month value. In this code, I am not using this variable mois for searching dates which belongs to this month. I am unable to achieve that.
Date_de_Survenance
30/01/2013
31/01/2013
31/01/2013
04/02/2013
05/02/2013
07/02/2013
11/02/2013
13/02/2013
13/02/2013
13/02/2013
15/02/2013
20/02/2013
See this example. I am not using the
Inputbox
for taking input but rather using a hard coded value for demonstration purpose.Lets say your Excel data looks like this.
Simply paste this code in a module and run it.
Code
Output