PDA

View Full Version : calculate salary for specific record



malarvel
08-14-2016, 10:59 PM
using below code I have calculate the salary for all the records.



Dim i As Integer
Dim totalpay As Double
'Calculate D.A & H.R.A
lastrow = Sheets("Earnings").Range("A" & Rows.Count).End(xlUp).Row
For i = 5 To lastrow
Cells(i, 11) = Round((Cells(i, 10) * Cells(4, 22)), 0)
Cells(i, 12) = Round((Cells(i, 10) * Cells(5, 22)), 0)
'Calculate T.A
Select Case Sheets("Earnings").Cells(i, 8)
Case 1800 To 1900
Cells(i, 13) = 900 + Round(900 * Cells(4, 22), 0)
Case 2000 To 4800
Cells(i, 13) = 1800 + Round(1800 * Cells(4, 22), 0)
Case Is >= 5400
Cells(i, 13) = 3600 + Round(3600 * Cells(4, 22), 0)
End Select
totalpay = (Cells(i, 10) + Cells(i, 11) + Cells(i, 12) + Cells(i, 13) + Cells(i, 14) + Cells(i, 15))
Cells(i, 16) = totalpay
Next i

For some instance i want to calculate the salary for specific record. Fox example, I have already calculate salary for the employees range from "A5:P21". Now i want to calculate salary for the 22nd record alone i.e range "A22:P22".

How to do this?

Aussiebear
08-14-2016, 11:17 PM
What's the relationship with the 22nd? For example, is it just an example date you picked out? Are other dates likely to be selected?