Hi,
I thought I had this fixed, but it's not exactly what I'm looking for.
This is what I have on my UserForm:
I have a SalaryListBox with four possible Values. I Have a Utilization TextBox which I would like to display as a percentage.
Student1.JPG
I need a formula that will take the Value for SalaryListBox multiply it by 7.5 (Hours in a Day) multiplied by number of days (DTPicker4)-(DtPicker3) and multiply by Utilization.
When I don't set the Utilization format a Percentage it works fine but, the User enters 1 and it shows up as 1 instead of 100% which is confusing.
Below is how it looks with the formula working:
Private Sub DTPicker3_Initialized()
DTPicker3.Value = Today()
End Sub
Private Sub DTPicker4_Initialized()
DTPicker4.Value = Today()
End Sub
Private Sub CancelButton_Click()
Unload UserForm3
FrmUpdate.Show
End Sub
Private Sub DTPicker3_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)
DTPicker3.Value = Date
End Sub
Private Sub DTPicker4_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)
DTPicker4.Value = Date
End Sub
Private Sub OKButton_Click()
Dim Position_Number_Addition As String
Dim searchTerm As Range
Dim NewSalary As Single
Position_Number_Addition = Casual_Position
NewSalary = CDbl(HourlyRate) * 7.5 * CDbl(Utilization) * (CDbl(DTPicker4) - CDbl(DTPicker3))
Set searchTerm = Worksheets("master").Range("A1:A999").Find(What:=Casual_Position, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious)
If searchTerm Is Nothing Then
MsgBox "Text was not found"
Else
searchTerm.Cells(2, 1).EntireRow.Insert Shift = xlDown
searchTerm.Cells.Activate
Selection.Offset(1, 0).Select
ActiveCell.Value = Position_Number_Addition
ActiveCell(1, 2).Value = TextBox1
ActiveCell(1, 3).Value = ComboBox1
ActiveCell(1, 4).Value = Position_Classification
ActiveCell(1, 5).Value = NewSalary
ActiveCell(1, 5).NumberFormat = "$0,000"
Columns("E").TextToColumns
ActiveCell(1, 6).Value = DTPicker3
ActiveCell(1, 7).Value = DTPicker4
ActiveCell(1, 8).Value = ActiveCell(1, 7).Value - ActiveCell(1, 6).Value
ActiveCell(1, 9).Value = Utilization
Columns("I").TextToColumns
ActiveCell(1, 10).Value = NewSalary
ActiveCell(1, 18).Value = WorksheetFunction.VLookup(Cost_CentreBox, Sheets("Cost_Centres").Range("a2:h250"), 3, False)
ActiveCell(1, 19).Value = WorksheetFunction.VLookup(Cost_CentreBox, Sheets("Cost_Centres").Range("a2:h250"), 4, False)
ActiveCell(1, 20).Value = WorksheetFunction.VLookup(Cost_CentreBox, Sheets("Cost_Centres").Range("a2:h250"), 2, False)
ActiveCell(1, 21).Value = Cost_CentreBox
Unload UserForm2
End If
FrmUpdate.Show
End Sub
This what I would like it to look like, but the Code isn't working (Code below):
Student2.JPG
Private Sub DTPicker3_Initialized()
DTPicker3.Value = Today()
End Sub
Private Sub DTPicker4_Initialized()
DTPicker4.Value = Today()
End Sub
Private Sub CancelButton_Click()
Unload UserForm3
FrmUpdate.Show
End Sub
Private Sub DTPicker3_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)
DTPicker3.Value = Date
End Sub
Private Sub DTPicker4_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)
DTPicker4.Value = Date
End Sub
Private Sub Utilization_Change()
Utilization.Value = Format(Utilization.Value, "0.00%")
End Sub
Private Sub OKButton_Click()
Dim Position_Number_Addition As String
Dim searchTerm As Range
Dim NewSalary As Single
Position_Number_Addition = Casual_Position
NewSalary = CDbl(HourlyRate) * 7.5 * CDbl(Utilization) * (CDbl(DTPicker4) - CDbl(DTPicker3))
Set searchTerm = Worksheets("master").Range("A1:A999").Find(What:=Casual_Position, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious)
If searchTerm Is Nothing Then
MsgBox "Text was not found"
Else
searchTerm.Cells(2, 1).EntireRow.Insert Shift = xlDown
searchTerm.Cells.Activate
Selection.Offset(1, 0).Select
ActiveCell.Value = Position_Number_Addition
ActiveCell(1, 2).Value = TextBox1
ActiveCell(1, 3).Value = ComboBox1
ActiveCell(1, 4).Value = Position_Classification
ActiveCell(1, 5).Value = NewSalary
ActiveCell(1, 5).NumberFormat = "$0,000"
Columns("E").TextToColumns
ActiveCell(1, 6).Value = DTPicker3
ActiveCell(1, 7).Value = DTPicker4
ActiveCell(1, 8).Value = ActiveCell(1, 7).Value - ActiveCell(1, 6).Value
ActiveCell(1, 9).Value = Utilization
Columns("I").TextToColumns
ActiveCell(1, 10).Value = NewSalary
ActiveCell(1, 18).Value = WorksheetFunction.VLookup(Cost_CentreBox, Sheets("Cost_Centres").Range("a2:h250"), 3, False)
ActiveCell(1, 19).Value = WorksheetFunction.VLookup(Cost_CentreBox, Sheets("Cost_Centres").Range("a2:h250"), 4, False)
ActiveCell(1, 20).Value = WorksheetFunction.VLookup(Cost_CentreBox, Sheets("Cost_Centres").Range("a2:h250"), 2, False)
ActiveCell(1, 21).Value = Cost_CentreBox
Unload UserForm2
End If
FrmUpdate.Show
End Sub
Can anyone tell me where my error is and how to fix it??
Thank-you in advance.
Bookmarks