Forum Discussion
Setting IF function to speak a sentence
- Sep 05, 2019
No problem, please test it as per your convenience and let me know if that works for you as desired.
Does A1 contain any formula which gets calculated based on other cells?
If yes, you can use the Calculate Event to speak the predefined text. To do so, right click on Sheet Tab --> View code --> and paste the code given below into the opened code window.
Private Sub Worksheet_Calculate()
If Range("A1").Value > 100 Then
Application.Speech.Speak "Congratulation!! You reached your goal!"
End If
End Sub
If you manually change the cell A1, replace the above code with the Change Event code...
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.CountLarge > 1 Then Exit Sub
If Target.Address(0, 0) = "A1" Then
If Target > 100 Then
Application.Speech.Speak "Congratulation!! You reached your goal!", True
End If
End If
End SubThe attached contains two sheets named "Calculate Event" and "Change Event" for you test the above codes.
If this is not what you are trying to achieve, please upload a sample workbook and explain that how do you want it to work.
Subodh_Tiwari_sktneerHi my friend. I tested your program this morning and it worked almost perfectly. The only problem was the voice started a loop and did not stop at all. I had to shut Excell (not only the specific sheet) to definitely quit the voice. I am attaching the sheet which will receive the voice command. I highlighted in yellow the column with the cells that will "produce" the voice. Please, let me know if I did something wrong. My best regards,
Marcelo