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.
Question
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.
Solution
Here is the VBA code to perform the actions you described:
- 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.
wksJanuary.Range("B1").Value = Val(strRate) / 100
- 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.
wksJanuary.Range("A19").Value = "Prepared By " & strName
This code assumes that the strRate variable contains a valid number that can be converted to a decimal, and that the strName variable contains a valid name. In a real-world scenario, you would want to add error checking to ensure that the inputs are valid before proceeding.
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.
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.
VBA寫法:在Excel儲存格B1的value為既有「日期」的年份,儲存格C1的value為儲存格B1的年份+1年。儲存格B2的value為另一新的年份,而儲存格C2的value為儲存格B2的年份+1年。在Excel儲存格A1:A10填寫了既有「日期」(d/m/yyyy)。現在以儲存格B2一的value取代儲存格A1:A10內B1日期的yyyy,及以儲存格C2的value取代儲存格A1:A10內C1日期的yyyy;但保留每一個儲存格內的d/m。
How do I calculate monthly target in Excel?
On the Year1 sheet, in cell B8, enter a formula to display the value of cell B7 from the Salaries sheet
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.