Text to speech particular cell

F

FunkyAnt13

hi
ive been trying for a while now to get the text to speech function to work
for a particular cell.

For example, i have a set of numbers and a total in D15, what i would like
is that if i change the numbers that contribute to that total, and the total
in D15 changes then excel will alert me saying "Change in Total".
ive tried and failed to get it notice the changed total and would really
appreciate some help

Thank You for any contributions
 
G

Gary''s Student

Let's put the message in a cell, say D16.

In a standard module insert the follow line:
Public OldVar As Variant

Insert the following event macro in the worksheet code area:

Private Sub Worksheet_Calculate()
If OldVar = Range("B15").Value Then Exit Sub
Range("B16").Speak
OldVar = Range("B15").Value
End Sub


Insert the following macro in the workbook code area:

Private Sub Workbook_Open()
OldVar = Sheets("Sheet1").Range("B15").Value
End Sub
 
F

FunkyAnt13

Thank you very much
Just a further question, if i wanted to add more cells how could i do that?
im thinking of being crude and just using the same code repeatedly, changing
the cell.
However ive tried that, but i know im not doing it right, i dont know if i
have to do it in the same worksheet or not, and if so then how do i avoid the
"ambiguous name detected" error.

As you can tell im very new to VBA

Once again, thanks for any help
 
G

Gary''s Student

You cannot replicate the subs. There can only be one sub of each type on
each worksheet/workbook.

You would need to use arrays within the subs to trap the different cells
that must be monitored.
 

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