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.
- mctribeiroSep 05, 2019Copper Contributor
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
- mctribeiroSep 05, 2019Copper ContributorHello my friend.
Thanks a lot for your quick response. The A1 cell is a result of other cells caculation, as your first assumption. I will test your command through your sheet example tomorrow and let you know the result. Thank you very much one more time.- Subodh_Tiwari_sktneerSep 05, 2019Silver Contributor
No problem, please test it as per your convenience and let me know if that works for you as desired.
- DebubAug 25, 2021Copper ContributorHi Sir,
I found that you have described how to use if function with speak cell I did it but one problem arises. Problem is the other cells are also speaking the same command even when the other cells value are different . Is it possible for you to resolve this problem as I want other cell not to speak.
Regards,
Debjit