• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Vba Code to make Excel Speak - Either or Or

Cammandk

Member
I have a file which when it opens I want excel to say 2 different lines of text depending if my budget is Under or Over.

If Budget is Over - "D1" = 0 , if Budget is under "D1" = 1

So if D1=0 - then text in A1 is read
If D1 =1 - then text in A2 is read

Thanks
Camman.
 
Put this code in the ThisWorkbook module of the VBE. Adjust as necessary.
Code:
Private Sub Workbook_Open()
Dim myCell As Range
Dim myMsg As String
'Where is the cell of interest?
With Worksheets("Sheet1")
    Set myCell = .Range("D1")
    
    'Check our criteria
    If myCell.Value = 0 Then
        myMsg = .Range("A1").Value
    ElseIf myCell.Value = 1 Then
        myMsg = .Range("A2").Value
    Else
        'Not sure if there are other options...
    End If
End With
Application.Speech.Speak myMsg
 
End Sub
 
@Luke M
Hi!
My workbooks are always uttering curses at me, should I check the language Excel version?
Regards!
 
Back
Top