Consulting

Results 1 to 2 of 2

Thread: calculate salary for specific record

  1. #1
    VBAX Regular
    Joined
    Aug 2016
    Posts
    12
    Location

    calculate salary for specific record

    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?
    Last edited by Aussiebear; 08-14-2016 at 11:12 PM. Reason: Added code tags to submitted code

  2. #2
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    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?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •