T
tuggers
I have the following code that was created for me by somebody else:
Sub myFixLeave()
'Sheet module code, like: Sheet1!
'Work with button code.
Dim myHTimeLeft&, myAns, myShts$, myUser$, myActivSht$
'Get each sheet name.
myActivSht = ActiveSheet.Name
For Each ws In Worksheets
'Add each found sheet name to a string.
myShts = myShts & ws.Name & ", "
'Go back and get the next users sheet name.
Next ws
myUser = InputBox("Enter the User you will be working with below:"
vbLf & vbLf & "[ " & myShts & "]", "Get User!")
If myUser = "" Then GoTo myEnd
'This is the Sheet and cell that has the time left data, for that user
myHTimeLeft = Sheets(myUser).Range("K29").Value
'Show box to get leave wanted responce!
myAns = InputBox("You have: " & myHTimeLeft & _
" hrs. of holiday time left!" & vbLf & vbLf & _
"Enter the holiday time time you wish to take off:", _
"Use Holiday Leave Time!", myHTimeLeft)
'Load answer to that users sheet and data cell that gets the answer!
If myAns <> xlNull And myAns <= myHTimeLeft Then
Sheets(myUser).Range("C5").Value = myAns
'Adjust Holiday leave for amount just taken on that users sheet!
Sheets(myUser).Range("K29").Value = Sheets(myUser).Range("K29").Value
myAns
'Test for taking more leave than you have!
ElseIf myAns <> xlNull And myAns > myHTimeLeft Then MsgBox "You do no
have, " & _
myAns & " hrs. of holiday leave left?" & vbLf & vbLf & _
"You have only, " & myHTimeLeft & " hrs. left!" & vbLf & vbLf & _
"You are, " & myAns - myHTimeLeft & " hrs. over your holiday leav
balance!", _
vbCritical + vbOKOnly, "Error: Exceeded your leave balance!"
End If
ActiveCell.Offset(0, 1).Select
myEnd:
End Sub
The code basically asks a user there name and amount of hours the
would like to take off, then posts that info to the users worksheet.
My question is - How would i change this so that, the input box ask
for a date when the amount of hours are chosen and then posts this dat
along with the amount of hours to the same row in a range on the user
sheet.
This would need to be posted to consecutive rows each time an entry i
made.
Any help would be greatly appreciated, and i would be incredibl
grateful
Sub myFixLeave()
'Sheet module code, like: Sheet1!
'Work with button code.
Dim myHTimeLeft&, myAns, myShts$, myUser$, myActivSht$
'Get each sheet name.
myActivSht = ActiveSheet.Name
For Each ws In Worksheets
'Add each found sheet name to a string.
myShts = myShts & ws.Name & ", "
'Go back and get the next users sheet name.
Next ws
myUser = InputBox("Enter the User you will be working with below:"
vbLf & vbLf & "[ " & myShts & "]", "Get User!")
If myUser = "" Then GoTo myEnd
'This is the Sheet and cell that has the time left data, for that user
myHTimeLeft = Sheets(myUser).Range("K29").Value
'Show box to get leave wanted responce!
myAns = InputBox("You have: " & myHTimeLeft & _
" hrs. of holiday time left!" & vbLf & vbLf & _
"Enter the holiday time time you wish to take off:", _
"Use Holiday Leave Time!", myHTimeLeft)
'Load answer to that users sheet and data cell that gets the answer!
If myAns <> xlNull And myAns <= myHTimeLeft Then
Sheets(myUser).Range("C5").Value = myAns
'Adjust Holiday leave for amount just taken on that users sheet!
Sheets(myUser).Range("K29").Value = Sheets(myUser).Range("K29").Value
myAns
'Test for taking more leave than you have!
ElseIf myAns <> xlNull And myAns > myHTimeLeft Then MsgBox "You do no
have, " & _
myAns & " hrs. of holiday leave left?" & vbLf & vbLf & _
"You have only, " & myHTimeLeft & " hrs. left!" & vbLf & vbLf & _
"You are, " & myAns - myHTimeLeft & " hrs. over your holiday leav
balance!", _
vbCritical + vbOKOnly, "Error: Exceeded your leave balance!"
End If
ActiveCell.Offset(0, 1).Select
myEnd:
End Sub
The code basically asks a user there name and amount of hours the
would like to take off, then posts that info to the users worksheet.
My question is - How would i change this so that, the input box ask
for a date when the amount of hours are chosen and then posts this dat
along with the amount of hours to the same row in a range on the user
sheet.
This would need to be posted to consecutive rows each time an entry i
made.
Any help would be greatly appreciated, and i would be incredibl
grateful