Use the Set statement to point the worksheet object variable to the January worksheet in this workbook. Use the InputBox function to prompt the user for his/her name. Store the user’s response in the string variable called strName.
Question
Use the Set statement to point the worksheet object variable to the January worksheet in this workbook. Use the InputBox function to prompt the user for his/her name. Store the user’s response in the string variable called strName.
Solution
Here is the VBA code to perform the actions you described:
- Declare the worksheet object variable and the string variable.
Dim wksJanuary As Worksheet
Dim strName As String
- Use the Set statement to point the worksheet object variable to the January worksheet in this workbook.
Set wksJanuary = ThisWorkbook.Sheets("January")
- Use the InputBox function to prompt the user for his/her name. Store the user’s response in the string variable called strName.
strName = InputBox("Please enter your name")
This code assumes that there is a worksheet named "January" in the workbook, and that the user will enter a valid name when prompted. In a real-world scenario, you would want to add error checking to ensure that the worksheet exists and that the user's input is valid.
Similar Questions
Commission Workbook Showing January Worksheet (Before)Finished worksheet (After)Pseudocode for the Commission Workbook’s Open Event Procedure (10 Marks)Declare two string variables strName and strRate and one WorkSheet object variable wksJanuary.Use the Set statement to point the worksheet object variable to the January worksheet in this workbook. Use the InputBox function to prompt the user for his/her name. Store the user’s response in the string variable called strName.Use the InputBox function to prompt the user for the commission rate as a whole number. Store the user’s response in the string variable called strRate.Convert the rate stored in the strRate variable to its decimal equivalent by converting to a number using the Val function then dividing by 100. Then assign the result to the cell B1 in the January worksheet.Concatenate the string literal constant “Prepared By ” to the name stored in the strName variable and assign the result to the cell A19 in the January worksheet.
Convert the rate stored in the strRate variable to its decimal equivalent by converting to a number using the Val function then dividing by 100. Then assign the result to the cell B1 in the January worksheet.Concatenate the string literal constant “Prepared By ” to the name stored in the strName variable and assign the result to the cell A19 in the January worksheet.
Write a statement to declare a worksheet object variable named wksTute6 and store the address of (or point to) the “Sheet2” worksheet in the “Tute6.xlsm” workbook.
You want to assign a specific name to a cell. You have used this same name previously for a different cell. Where can you view the sheet and cell reference that indicates where the name has been assigned?1 pointUse the Name box on the top left of the worksheet.Use the Search feature at the top of the Excel window and type the name.Use the Name Manager in the Formulas ribbon5.
Write a statement to declare a workbook object variable named wkbTute6 and store the address of (or point to) the “Tute6.xlsm” workbook.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.