Matching Value placed in next column

C

Corey

I am still to work out an effective solution to this:
I have a list of dates in a (mmmm yy) format in Sheet1 Range(B17:B28)
At the end of a macro in another sheet I want to place Now() in a
(mmmm yy) format in the Cell NEXT to the MATCHING Value in Column C.

I have yet to workout how to MATCH the values so the MATCHING mmmm yy
is placed NEXT to the mmmm yy in Column B.

I need to code this as say:

If Now() = Sheet1.Range(B17:B28).Cells.Value then
Sheet1.Range(B17:B28).Cells.Activate
ActiveCell.Offset(0,1).value = Now()

end sub



How can I code this logically to actually work?

Corey....
 
D

Dave Peterson

First, this is a plain text newsgroup. Most regulars don't like attachments or
HTML posts.

But Now is pretty fine time. You have to match date, time (done to the
second???).

And if you want to match the complete date (no matter how it's formatted in the
cell), you could use something like:

Option Explicit
Sub testme01()
Dim res As Variant
res = Application.Match(CLng(Date), Range("b17:b28"), 0)
If IsError(res) Then
MsgBox "no match"
Else
MsgBox "match on row: " & res + Range("b17").Row - 1
End If
End Sub

But if you don't know the days that are in B17:B28, I'd just loop through them.

Option Explicit
Sub testme01()
Dim FoundAMatch As Boolean
Dim myRng As Range
Dim myCell As Range

Set myRng = ActiveSheet.Range("b17:b28")

FoundAMatch = False
For Each myCell In myRng.Cells
If Format(myCell, "mmmm yy") = Format(Date, "mmmm yy") Then
FoundAMatch = True
Exit For
End If
Next myCell

If FoundAMatch Then
MsgBox "match on row: " & myCell.Row
Else
MsgBox "no match"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top