(Solved) : Modify Excel Macro Called Currencyconversion Replace Else Statements Used Check User Input Q37235070 . . .
Modify the Excel Macro called CurrencyConversion and replace theIf,then, else statements that are used to check for userinput errors with the select case statement. Verify yourprogram runs without errors. THE MACRO CODE IS LISTED BELOW.
Public Sub CurrencyConversion()
‘—————————————-
‘Variable declaration
‘—————————————-
Dim ratefrom As String ‘rate exchanging from
Dim RateTo As String ‘ rate exchanging to
Dim amount As Double ‘amount to be converted
Dim rateval As Double ‘exchange rate value
Dim RateFromidx As Integer ‘ row number
Dim RateToidx As Integer ‘ column number
Dim foundFrom As Boolean ‘found the rate to convert from
Dim foundTo As Boolean ‘found the rate to convert to
‘—————————————-
‘Begin of code
‘—————————————-
ratefrom = InputBox(“Enter the rate you are exchanging from”)
‘MODIFY THE CODE BELOW THIS LINE
‘Check to see if value is correct
If ratefrom = “USD” Then
foundFrom = True
ElseIf ratefrom = “GBP” Then
foundFrom = True
ElseIf ratefrom = “CAD” Then
foundFrom = True
ElseIf ratefrom = “EUR” Then
foundFrom = True
ElseIf ratefrom = “AUD” Then
foundFrom = True
Else
foundFrom = Falsel
End If
If foundFrom Then
RateTo = InputBox(“Enter the rate you are exchanging to”)
‘MODIFY THE CODE BELOW THIS LINE
‘Check to see if value is correct
If RateTo = “USD” Then
foundTo = True
ElseIf RateTo = “GBP” Then
foundTo = True
ElseIf RateTo = “CAD” Then
foundTo = True
ElseIf RateTo = “EUR” Then
foundTo = True
ElseIf RateTo = “AUD” Then
foundTo = True
Else ‘Found to
foundTo = False
End If
End If
‘End of change
‘——————
If ((foundFrom = True) And (foundTo = True)) Then
amount = InputBox(“Enter the amount to be converted”)
RateFromidx = Application.WorksheetFunction.Match(ratefrom,Range(“A2:A6”), 0)
RateToidx = Application.WorksheetFunction.Match(RateTo,Range(“A2:A6”), 0)
rateval = Application.WorksheetFunction.Index([B2:F6], RateFromidx,RateToidx)
MsgBox amount & ” in ” & ratefrom & ” equals ” &amount / rateval & ” in ” & RateTo
Else
MsgBox “Invalid currency value entered. “
End If
‘End of change
‘——————
End Sub
Expert Answer
Answer to Modify the Excel Macro called CurrencyConversion and replace the If,then, else statements that are used to check for use…
OR