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.
Subodh_Tiwari_sktneerhere I come again. I found out when the loop happens. The original sheet, with some cells which numbers come from another program via DDE, Dinamic Data Exchange, in real time the voice starts an endless loop when the condition is reached but in the sheet I sent you, with frozen cells, your program works perfectly (exception: if one the cells used in the formula turns to something else but a number the VBA bugs).
The code I proposed was supposed to work for a single cell A1.
In your sample file, are you looping through the column U and want the code to check the formula output for multiple cells in column U and then speak the text once a specific output is returned by the formula in one or more cells?
Since this is the Calculate event, each time Sheet is recalculated the code will be triggered and check the target cell/cells for the output returned by the formula and if that meets the criteria, the code will invoke the speech method and to handle this scenario, you can place a flag once the text is spoken for a cell either by using a helper column and placing a flag in there or you can change the cell color so that the code can check before speaking the text if the cell color is not a specific color i.e. once the code speaks the text for a cell, change the cell color to say Red and the next time code will check the cell color and if it is red, it will skip and won't speak the text for the same cell again.
As far as the VBA errors are concerned when the value is not numeric, I think the code will produce an error if the cell has an error in it which you can easily check in the code with an IF condition like If Not IsError(Range("A1")) Then.
- mctribeiroSep 05, 2019Copper Contributor
Actually I thought it as well but a "voice alert" would work better. However I undertand your point. There is another solution do make the macro's work lighter: split my worksheet in several different sheets, each one with its own macro. Well, I do not know. Let me see how hard it would be to decide which way I will take. Anyway, I don't want to push you with this demand. Thanks a lot Subodh_Tiwari_sktneer for your valuable help. I will keep trying.
- Subodh_Tiwari_sktneerSep 05, 2019Silver Contributor
Honestly, in my opinion, forcing the macro to speak out several sentences in one go would be like overuse of this feature. Why not add some visuals on the sheet once one or more criteria are met?
- mctribeiroSep 05, 2019Copper Contributor
Subodh_Tiwari_sktneermy idea is to write an specific sentence for each cell in column "U" as each line refers to a different information. How can write a formula that consider it or is it to complicate?