Thankyou for your responce,
The output cell is within a table and simply displays nothing! But if the result is positive it shows a value as i would expect.
Possibly there are issues where the numbers come from that go into the code if it works fine for you.
The TargetRateTextBox is different dependant on the selection made by the user in the userform from a combobox (GenreSubSectionCBO), the Jobsummary worksheet is where the sheet administrator types the target rates that populate the userform.
The TargetRateTextBox is populated from the worksheet dependant on a selection using the code;
Private Sub GenreSubSectionCBO_Change()
Dim JobSummaryWS As Worksheet
Set JobSummaryWS = Worksheets("JobSummary")
If Me.GenreSubSectionCBO.Column(0) = JobSummaryWS.Cells(19, 3) Then Me.TargetRateTextBox.Value = JobSummaryWS.Cells(19, 5)
If Me.GenreSubSectionCBO.Column(0) = JobSummaryWS.Cells(20, 3) Then Me.TargetRateTextBox.Value = JobSummaryWS.Cells(20, 5)
If Me.GenreSubSectionCBO.Column(0) = JobSummaryWS.Cells(21, 3) Then Me.TargetRateTextBox.Value = JobSummaryWS.Cells(21, 5)
If Me.GenreSubSectionCBO.Column(0) = JobSummaryWS.Cells(22, 3) Then Me.TargetRateTextBox.Value = JobSummaryWS.Cells(22, 5)
If Me.GenreSubSectionCBO.Column(0) = JobSummaryWS.Cells(23, 3) Then Me.TargetRateTextBox.Value = JobSummaryWS.Cells(23, 5)
If Me.GenreSubSectionCBO.Column(0) = JobSummaryWS.Cells(24, 3) Then Me.TargetRateTextBox.Value = JobSummaryWS.Cells(24, 5)
If Me.GenreSubSectionCBO.Column(0) = JobSummaryWS.Cells(25, 3) Then Me.TargetRateTextBox.Value = JobSummaryWS.Cells(25, 5)
If Me.GenreSubSectionCBO.Column(0) = JobSummaryWS.Cells(26, 3) Then Me.TargetRateTextBox.Value = JobSummaryWS.Cells(26, 5)
If Me.GenreSubSectionCBO.Column(0) = JobSummaryWS.Cells(27, 3) Then Me.TargetRateTextBox.Value = JobSummaryWS.Cells(27, 5)
If Me.GenreSubSectionCBO.Column(0) = JobSummaryWS.Cells(28, 3) Then Me.TargetRateTextBox.Value = JobSummaryWS.Cells(28, 5)
Pic of worksheet where target rate is initially inputted by administrator;
Screen Shot 2012-07-17 at 08.57.18.png
The RateTextBox code is;
Me.RateTextBox.Value = CDbl(CostTotalsTextBox.Value) / CDbl(ActProductionTextBox.Value)
The Cost Totals Text Box code works out all machine and labour costs minus any deductions.
The Activity production is a user typed textbox which i have tried to make stronger code as suggested in the first reply which told me to make sure the user inputs a numeric value with the if IsNumeric code, when i have applied this to my original code I get a Run-time error 13 'Type Mismatch'.
This is the code as advised;
If IsNumeric(ActivityProductionTextBox.Value) Then
Me.RateTextBox.Value = CDbl(CostTotalsTextBox.Value) / CDbl(ActProductionTextBox.Value)
Else
MsgBox "The Activity Production Box must be numeric, please correct"
MultiPage1.Value = 0
Me.ActivityProductionTextBox.SetFocus
Exit Sub
End If
Sorry I know this is lots of info and probably makes more sense to me than to anyone else not working on my project, if you need any more info to help me then please ask.
Many Thanks,
Bookmarks