Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7
Default 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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
User defined functions without using VBA. [email protected] New Users to Excel 0 June 13th 06 05:55 PM
User defined functions without using VBA. [email protected] Excel Discussion (Misc queries) 0 June 13th 06 05:50 PM
User defined functions without using VBA. [email protected] Excel Worksheet Functions 0 June 13th 06 05:44 PM
Nesting functions in the functions dialog box cs170a Excel Worksheet Functions 0 June 10th 05 10:36 PM
How can I create a formula out of more than 7 functions in excel? Dolores Excel Worksheet Functions 3 May 19th 05 09:28 PM


All times are GMT +1. The time now is 07:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"