Results 1 to 2 of 2

Userform Asking for percentage but cannot calculate

Threaded View

FranktheBank Userform Asking for... 06-06-2016, 12:54 PM
FranktheBank Re: Userform Asking for... 06-06-2016, 01:10 PM
  1. #1
    Registered User
    Join Date
    09-27-2012
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    62

    Userform Asking for percentage but cannot calculate

    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.
    Attached Images Attached Images
    Last edited by FranktheBank; 06-06-2016 at 03:14 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. not sure how to formulate my question
    By Excel layman in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-14-2015, 08:09 AM
  2. how to formulate A..B..C...AA AB AC..etc
    By xianwinwin in forum Excel General
    Replies: 4
    Last Post: 03-16-2011, 09:05 PM
  3. Formulate a list
    By money n da sank in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-25-2010, 11:47 AM
  4. Showing persentage as label
    By salmanucit in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 01-12-2010, 04:56 AM
  5. Show Data Lables show Amount & Persentage at the same time
    By ComcoDG in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-29-2008, 04:54 AM
  6. Formulate a Column ?
    By NT_eyeball in forum Excel General
    Replies: 2
    Last Post: 08-15-2005, 11:05 AM
  7. visual persentage like effect & referance cells
    By J_J in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-05-2005, 07:06 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1