The attached Excel sheet has VBA codes in the editor window 3 subs. The instructions on the expected codes' logic is pro

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

The attached Excel sheet has VBA codes in the editor window 3 subs. The instructions on the expected codes' logic is pro

Post by answerhappygod »

The attached Excel sheet has VBA codes in the editor window 3subs. The instructions on the expected codes' logic is provided asa comment in the visual basic editor.
There are syntax error, and logical errors. Solve all the errorsand make sure that the 3 subs are working correctly.
code :
'This code would highlight alternate rows in the selection fromRange A1:A10Sub HighlightAlternateRows()Dim Myrange As RangeDim Myrow As IntegerRange("A1:A10").SelectSet Myrange = SelectionFor Each Myrow In Myrange.Rows If Myrow.Row Mod 2 = 1 Myrow.Interior.Color = vbCyan End IfNext MyrowEnd Sub
'This code will change the values from A1:A24 to UpperCaseSub ChangeCase()Dim Rng As RangeRange("A1:A23").Select
For Each Rng In Selection.CellsIf Rng.HasFormula = False ThenRng.Value = UCase(Rng.Value)Next RngEnd 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 asforward,'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 apalindrome or not") Palindromecheck = "Trues" 'initialize the booleanvariable to true idx = 1 ldx = Length(getStr) ' measures the length of theentered string
'Strip only numbers (1-9) & albhabets (A-Z anda-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 astring iStr = iStr &UCase(Mid(getStr, idx, 1)) End If idx = idx + 1 Wend 'Check whether reverse of string is also same forPalindrome 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 displaymessage Else MsgBox ('The word " & iStr & "is NOT a Palindrome") End IfEnd Sub
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply