I have the following macro (that works):
It compares data between sheet 1 and sheet 2, when there is a match a message pops up and a sound plays. However this is only limited to column A on sheet 1 and column A on sheet 2. Each column on sheet 1 represents a specific day, data is inputted into the respective column for the day.
When data is inputted into sheet 2 and it is being matched to data in sheet 1, I want it to match the column that reflects today's date.
I found a macro that selects todays date:
Hope that helps
I basically don't want to make a separate excel document for each day
Code:
Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Dim NewCodeToFind As String
Dim RowNumber As Integer
Set KeyCells = Range("A:A")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
Range("A1").Select
Selection.End(xlDown).Select
NewCodeToFind = Selection.Value
RowNumber = 2
Do Until IsEmpty(Worksheets(2).Cells(RowNumber, 1))
If Worksheets(2).Cells(RowNumber, 1) = NewCodeToFind Then
If Not Worksheets(2).Cells(RowNumber, 2) = 1 Then
Call PlaySound("c:\windows\media\tada.wav", _
0, SND_ASYNC Or SND_FILENAME)
MSG1 = MsgBox(NewCodeToFind & " FOUND?", vbYesNo, "***FOUND***")
If MSG1 = vbYes Then
Worksheets(2).Cells(RowNumber, 2) = 1
Exit Sub
Else
Worksheets(2).Cells(RowNumber, 2) = 0
End If
End If
End If
RowNumber = RowNumber + 1
Loop
End If
End Sub
It compares data between sheet 1 and sheet 2, when there is a match a message pops up and a sound plays. However this is only limited to column A on sheet 1 and column A on sheet 2. Each column on sheet 1 represents a specific day, data is inputted into the respective column for the day.
When data is inputted into sheet 2 and it is being matched to data in sheet 1, I want it to match the column that reflects today's date.
I found a macro that selects todays date:
Code:
Sub SelectDate()
Dim fR As Range
With Me.Range("A1:N1")
Set fR = .Find(what:=Date, after:=Range("A1"), LookIn:=xlValues, lookat:=xlWhole)
If Not fR Is Nothing Then fR.Select
End With
Hope that helps
I basically don't want to make a separate excel document for each day