**The below screenshot has VBA codes in the editor windo 3 subs. The instructions on the expected codes ' logic is provided as a comment in the visual basic edito. there are syntax error, and logical errors. solve the errors and make sure that the 3 subs are working correctly. *** Option Explicit 'This code would highlight alternate rows in the selection from Range A1:A10 Sub HighlightAlternateRows() Dim Myrange As Range Dim Myrow As Integer Range("A1:A10").Select Set Myrange = Selection For Each Myrow In Myrange.Rows If Myrow.Row Mod 2 = 1 Myrow.Interior.Color = vbCyan End If Next Myrow End Sub 'This code will change the values from A1:A24 to Upper Case Sub ChangeCase() Dim Rng As Range Range("A1:A23").Select For Each Rng In Selection.Cells If Rng.HasFormula = False Then Rng.Value = UCase(Rng.Value) Next Rng End If End Sub Sub Palindrome() 'Checks if the entered value is a Palindrome. 'A palindrome is a word, number, phrase, or other 'sequence of characters which reads the same backward as forward, 'such as madam, racecar, detartrated, rotavator. Dim iStr As String Dim idx As Integer, ldx As Integer Dim getStr As String Dim Palindromecheck As Boolean getStr = InputBox("Enter a word to check if it is a palindrome or not") Palindromecheck = "Trues" 'initialize the boolean variable to true idx = 1 ldx = Length(getStr) ' measures the length of the entered string 'Strip only numbers (1-9) & albhabets (A-Z and a-z) from input string While (idx <= ldx) If (Mid(getStr, idx, 1) Like "[1-9A-Za-z]") Then 'checks if each character is a number or a string iStr = iStr & UCase(Mid(getStr, idx, 1)) End If idx = idx + 1 Wend 'Check whether reverse of string is also same for Palindrome idx = 1 ldx = Len(iStr) While (idx < ldx) If (Mid(iStr, idx, 1) <> Mid(iStr, ldx, 1)) Then Palindromecheck == False End If idx = idx + 1 ldx = ldx - 1 Wend If Palindromecheck == True Then MsgBox ("The word " iStr & " is a Palindrome") ' concatenate the strings to display message Else MsgBox ('The word " & iStr & " is NOT a Palindrome") End If End Sub
**The below screenshot has VBA codes in the editor windo 3 subs. The instructions on the expected codes ' logic is provided as a comment in the visual basic edito. there are syntax error, and logical errors. solve the errors and make sure that the 3 subs are working correctly. ***
Option Explicit
'This code would highlight alternate rows in the selection from Range A1:A10
Sub HighlightAlternateRows()
Dim Myrange As Range
Dim Myrow As Integer
Range("A1:A10").Select
Set Myrange = Selection
For Each Myrow In Myrange.Rows
If Myrow.Row Mod 2 = 1
Myrow.Interior.Color = vbCyan
End If
Next Myrow
End Sub
'This code will change the values from A1:A24 to Upper Case
Sub ChangeCase()
Dim Rng As Range
Range("A1:A23").Select
For Each Rng In Selection.Cells
If Rng.HasFormula = False Then
Rng.Value = UCase(Rng.Value)
Next Rng
End If
End Sub
Sub Palindrome()
'Checks if the entered value is a Palindrome.
'A palindrome is a word, number, phrase, or other
'sequence of characters which reads the same backward as forward,
'such as madam, racecar, detartrated, rotavator.
Dim iStr As String
Dim idx As Integer, ldx As Integer
Dim getStr As String
Dim Palindromecheck As Boolean
getStr = InputBox("Enter a word to check if it is a palindrome or not")
Palindromecheck = "Trues" 'initialize the boolean variable to true
idx = 1
ldx = Length(getStr) ' measures the length of the entered string
'Strip only numbers (1-9) & albhabets (A-Z and a-z) from input string
While (idx <= ldx)
If (Mid(getStr, idx, 1) Like "[1-9A-Za-z]") Then 'checks if each character is a number or a string
iStr = iStr & UCase(Mid(getStr, idx, 1))
End If
idx = idx + 1
Wend
'Check whether reverse of string is also same for Palindrome
idx = 1
ldx = Len(iStr)
While (idx < ldx)
If (Mid(iStr, idx, 1) <> Mid(iStr, ldx, 1)) Then
Palindromecheck == False
End If
idx = idx + 1
ldx = ldx - 1
Wend
If Palindromecheck == True Then
MsgBox ("The word " iStr & " is a Palindrome") ' concatenate the strings to display message
Else
MsgBox ('The word " & iStr & " is NOT a Palindrome")
End If
End Sub
Step by step
Solved in 3 steps with 3 images