Consulting

Results 1 to 17 of 17

Thread: Help with a simple VBA

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    VBAX Regular
    Joined
    Nov 2015
    Posts
    9
    Location
    Hi again !

    So Here is the macro I have created:

    Dim NAME As String
    Dim OVERTIME As Integer
    Dim ABSENT As Integer
    Dim X As Integer
    Dim Bonus As Integer
    NAME = InputBox("Enter name")
    OVERTIME = InputBox("Enter hours of overtime")
    ABSENT = InputBox("Enter hours of absenteism")
    X = OVERTIME - 2 * ABSENT / 3
    If X > 40 Then Bonus = 50
    If X > 30 And X <= 40 Then Bonus = 40
    If X > 20 And X <= 30 Then Bonus = 30
    If X > 10 And X <= 20 Then Bonus = 20
    If X <= 10 Then Bonus = 10
    MsgBox ("Bonus" & Bonus)
    It works so I'm content (it may seem trivial and flawed to you but as I said I only just began so I only know the very basic stuff) anyway I was wondering if you could see anything really wrong with it, or something I could obviously improve about it?
    For instance, should some of the data be introduced As Double (Dim ... As Double)?
    Many thanks again
    Last edited by SamT; 12-02-2015 at 04:50 PM.

Posting Permissions

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