Question: '3. (45 Points - 35 min) Using the Developer Tab, place a button on the worksheet named Problem3. ' in VBE place your code in
'3. (45 Points - 35 min) Using the Developer Tab, place a button on the worksheet named Problem3. ' in VBE place your code in a sub named Problem3 in module Prob3. ' When the button is clicked, a VBA macro should run the code that will do the following. ' (Note, if you do not know how to code some of the steps, write the code for whatever steps ' you do know. For example, if you do not know how to get the name from the specified cell, ' assume that the name is given to you in a string variable and process that string variable ' so that you can get credit for the parts of the code you can write.) ' IN THE FOLLOWING ITEMS, PUT YOUR FIRST NAME AS THE TITLE OF INPUT AND MESSAGE BOXES. ' ' a. Using VBA, clear cells F1 to F10 ' b. Using an input box ask the user to enter a sentence with at least three words separated ' by blank spaces. Assign the sentence to a string variable and write it to cell F1 ' (you DO NOT HAVE TO CHECK to determine if it has at least three words). ' c. Determine the number of leading blanks and the number of trailing blanks (if any) and ' assign the numbers to variables. ' d. Delete any leading and trailing blanks and assign the resulting cleaned sentence to a ' string variable. ' e. Write in a message box "The sentence was cleaned by deleting # leading blanks and # ' trailing blanks." For example if the sentence was "I Am a CaT " then ' the message would be "The sentence was cleaned by deleting 0 leading blanks and 2 ' trailing blanks." (Note: the sentence may include multiple blanks and erratic ' capitalization.) ' f. Using a message box with Yes and No buttons ask the question. ' "Do you want to create a password with the sentence?" and on the FOLLOWING line the ' cleaned out sentence; e.g., "I Am a CaT" ' g. If the user responds No, then no password is generated. Write to cell F2 the message ' "Thank you" and interrupt execution of the code so that no other statements are executed. ' h. If the user responds Yes, then a password is created as follows: the last word in the ' sentence written backwards with the first character of the reversed word capitalized ' and the rest in lower case followed by the number of characters of the remainder of the ' sentence after excluding trailing and leading blanks; e.g., if the cleaned up sentence ' is "I Am a CaT" then the password would be "Tac16" because ' "I Am a" has 16 characters including the blanks between words. ' i. Write the password to the cell "F#" in the current worksheet, where # is a random number ' between 2 and 9 that can be generated with the Excel function Randbetween. ' j. Write the time in MINUTES that it took to run the program to the cell immediately below ' the cell where the password was printed; that is, if the password was written in cell F7, ' then the time should be in cell F8. (Note that each time you run the program, ' the results may be written in different cells.) ' k. Anything not specified is at your discretion.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
