Hi all,
I have the macro below, in the BOLD part, it finds TODAY'S DATE and make that cell active.
How do I change it to FIND THIS MONTH?
My columns include months such as 8/1/07 display as "Aug 07"....
Days do not matter, if it finds THIS MONTH (ex:Aug 07), then make that cell active. Thanks
Sub Macro1()
Dim rng1 As Range
Dim dateToFind As Date
Dim foundDate As Range
dateToFind = Date 'This is today's date
Set rng1 = Range(Cells(4, 2), _
Cells(Columns.Count, 1).End(xlToRight))
Set foundDate = rng1.Find(What:=dateToFind, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not foundDate Is Nothing Then
foundDate.Select
Else
MsgBox dateStr & " not found"
End If
ActiveCell.Offset(10, 0).Select
Set leftCell = ActiveCell
Set RightCell = Cells(ActiveCell.Row, 29)
Range(leftCell, RightCell).Select
Selection.Copy
ActiveCell.Offset(-6, 0).Select
Selection.PasteSpecial Paste:=xlValues
ActiveCell.Offset(6, 0).Select
ActiveCell.ClearContents
End Sub
I have the macro below, in the BOLD part, it finds TODAY'S DATE and make that cell active.
How do I change it to FIND THIS MONTH?
My columns include months such as 8/1/07 display as "Aug 07"....
Days do not matter, if it finds THIS MONTH (ex:Aug 07), then make that cell active. Thanks
Sub Macro1()
Dim rng1 As Range
Dim dateToFind As Date
Dim foundDate As Range
dateToFind = Date 'This is today's date
Set rng1 = Range(Cells(4, 2), _
Cells(Columns.Count, 1).End(xlToRight))
Set foundDate = rng1.Find(What:=dateToFind, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not foundDate Is Nothing Then
foundDate.Select
Else
MsgBox dateStr & " not found"
End If
ActiveCell.Offset(10, 0).Select
Set leftCell = ActiveCell
Set RightCell = Cells(ActiveCell.Row, 29)
Range(leftCell, RightCell).Select
Selection.Copy
ActiveCell.Offset(-6, 0).Select
Selection.PasteSpecial Paste:=xlValues
ActiveCell.Offset(6, 0).Select
ActiveCell.ClearContents
End Sub