Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Want to create functions for Child maths
Help someone, HELP. Excel 2003 problem.
I am trying to do a spreadsheet for my son to help him in the maths area of his schoolwork. What is the formula to put in a cell, that if he gets the answer correct, the cell would turn green and a sound clip could play with cheers, and if he got it wrong, the cell would turn red with a sound clip that could say, Try again. I would be most appreciative if someone could help me on this, or if they could ask a friend who is a fundi @ excel. |
#2
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
Want to create functions for Child maths
Simplest way is to have the correct result in a column off-screen (BA or
so), and then have change event on the answer column. Something like Option Explicit 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) Const WS_RANGE As String = "H:H" '<=== change to suit Const WS_ANSWER As String = "BA" '<=== change to suit Const WAV_CORRECT As String = "C:\Windows\Media\tada.wav" Const WAV_INCORRECT As String = "C:\Windows\Media\Windows XP Error.wav" Dim nMax As Long On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If .Value = "" Then .Interior.ColorIndex = xlColorIndexNone ElseIf .Value = Me.Cells(.Row, WS_ANSWER).Value Then .Interior.ColorIndex = 50 PlayWAVFile WAV_CORRECT Else .Interior.ColorIndex = 3 PlayWAVFile WAV_INCORRECT End If End With End If ws_exit: Application.EnableEvents = True End Sub Private Sub PlayWAVFile(ByVal WavFile As String, Optional Async As Boolean = True) If Async Then Call PlaySound(WavFile, 0&, SND_ASYNC Or SND_FILENAME) Else Call PlaySound(WavFile, 0&, SND_SYNC Or SND_FILENAME) End If End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "Iceman" wrote in message ... Help someone, HELP. Excel 2003 problem. I am trying to do a spreadsheet for my son to help him in the maths area of his schoolwork. What is the formula to put in a cell, that if he gets the answer correct, the cell would turn green and a sound clip could play with cheers, and if he got it wrong, the cell would turn red with a sound clip that could say, Try again. I would be most appreciative if someone could help me on this, or if they could ask a friend who is a fundi @ excel. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
User defined functions without using VBA. | New Users to Excel | |||
User defined functions without using VBA. | Excel Discussion (Misc queries) | |||
User defined functions without using VBA. | Excel Worksheet Functions | |||
Nesting functions in the functions dialog box | Excel Worksheet Functions | |||
How can I create a formula out of more than 7 functions in excel? | Excel Worksheet Functions |