Hi all,
This is my first post and I hope it is clear and I thank you in advance for your help. I have created a simple translation cost and delivery calculator in VBA (which sends data to a worksheet for calculations) so users can enter the number of words they need to translate and their preferred delivery date. Once they enter this data and click Update, the form retrieves the translation costs from a cell, retrieves the rush (due to larger volumes in shorter delivery time) from a cell, and combines both to display total cost.
As many times the users will ask for impossible delivery times, my worksheet contains formulas that calculate the number of words possible in the rush cell and either returns the percentage extra they will pay or says "Not Possible" if it is not. My problem is, I do not know how to write a Sub that, after update, checks the rush cell in my worksheet and displays a Msgbox if the returned value is "Not Possible" BEFORE giving me a type mismatch error as the rush percentage is not numeric.
I hope this makes sense but happy to clarify and thank you again for any help. I've included my code as this may be helpful:
Sub Showme()
FrmProducts.Show
End Sub
Private Sub cmdClear_Click()
'clear the values
With Me
.txtWords.Value = ""
.txtPage.Value = ""
.txtDelivery.Value = ""
.txtRush.Value = ""
.txtTranscost.Value = ""
.txtDTPCost.Value = ""
.txtTotal.Value = ""
End With
End Sub
Private Sub Label11_Click()
End Sub
Private Sub txtWords_Change()
With Sheet1
.Range("G5").Value = Me.txtWords.Value
End With
'update the worksheet
Application.ScreenUpdating = True
End Sub
Private Sub txtWords_AfterUpdate()
'check for values and datatype
If Not IsNumeric(Me.txtWords.Value) Then
MsgBox "Please add number of words"
Me.txtWords.Value = ""
Exit Sub
End If
End Sub
Private Sub txtPage_Change()
ActiveSheet.Protect UserInterfaceOnly:=True
With Sheet1
.Range("H5").Value = Me.txtPage.Value
End With
'update the worksheet
Application.ScreenUpdating = True
End Sub
Private Sub txtPage_AfterUpdate()
ActiveSheet.Protect UserInterfaceOnly:=True
'check for values and datatype
If Not IsNumeric(Me.txtPage.Value) Then
MsgBox "Please add number of DTP Pages. If none, please add 0)"
Me.txtPage.Value = ""
Exit Sub
End If
End Sub
Private Sub txtDelivery_Change()
ActiveSheet.Protect UserInterfaceOnly:=True
With Sheet1
.Range("I5").Value = Me.txtDelivery.Value
End With
'update the worksheet
Application.ScreenUpdating = True
End Sub
Private Sub txtDelivery_AfterUpdate()
ActiveSheet.Protect UserInterfaceOnly:=True
'check for values and datatype
If Not IsNumeric(Me.txtDelivery.Value) Then
MsgBox "Please add number of business days required for delivery)"
Me.txtDelivery.Value = ""
Exit Sub
End If
End Sub
Private Sub cmdCost_Click()
ActiveSheet.Protect UserInterfaceOnly:=True
With Me
.txtTranscost.Value = Sheet1.Range("H13").Value
.txtTranscost.Value = Format(Me.txtTranscost.Value, "€#,##0.00")
.txtDTPCost.Value = Sheet1.Range("I13").Value
.txtDTPCost.Value = Format(Me.txtDTPCost.Value, "€#,##0.00")
.txtRush.Value = Sheet1.Range("H18").Value
.txtRush.Value = Format(Val(Me.txtRush.Value), "0%")
.txtTotal.Value = Sheet1.Range("I18").Value
.txtTotal.Value = Format(Me.txtTotal.Value, "€#,##0.00")
End With
End Sub
Bookmarks