Question: Update the salary of employees in a specific department by a given percentage.
Employee ID
101
102
103
104
105
Access the Macro:
Press Alt + F8 in Excel to open the Macro dialog box.
Select the macro UpdateSalaries and click "Run."
Input Required Information:
code to be written Sub UpdateSalaries()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
Dim department As String
Dim increment As Double
Set ws = ThisWorkbook.Sheets("Employees")
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
' Prompt user for department and percentage increment
department = InputBox("Enter the department to update salaries (e.g., Sales):")
increment = InputBox("Enter the percentage increment (e.g., 10 for 10%):") / 100
For i = 2 To lastRow
If ws.Cells(i, 3).Value = department Then
ws.Cells(i, 4).Value = ws.Cells(i, 4).Value * (1 + increment)
End If
Next i
MsgBox "Salaries updated for " & department & " department."
End Sub
Enter the department name when prompted (e.g., "Sales").
Enter the percentage increment (e.g., 10 for a 10% salary increase).
Macro Execution:
The macro will loop through the "Employees" sheet, identify rows matching the entered department, and increase their sal
1%
Name Department Salary
Alice HR 50000
Bob Sales 72000
Charlie IT 70000
Diana Finance 80000
Edward Sales 66000
Note:use proper explanation
department, and increase their salaries by the specified percentage.
Question: Generate a sales summary report based on the selected region and month.
Sale ID Employee ID Region Month Sales Amount
201 102 North Jan 15000
202 105 South Jan 20000
203 102 East Feb 18000
204 103 West Feb 22000
205 104 North Mar 25000
Access the Macro:
Press Alt + F8 in Excel to open the Macro dialog box.
Select the macro UpdateSalaries and click "Run."
Input Required Information:
Enter the department name when prompted (e.g., "Sales").
Enter the percentage increment (e.g., 10 for a 10% salary increase).
Macro Execution:
The macro will loop through the "Employees" sheet, identify rows matching the entered department,
hing the entered department, and increase their salaries by the specified percentage.
Question: Update the price of products in a specific category by a given percentage.
Product ID Product Name
301 Laptop
302 Tablet
303 Phone
304 Monitor
305 Printer
Category Price
Electronics 1000
Electronics 500
Electronics 300
Accessories 150
Accessories 200