Results 1 to 2 of 2

Trigger message box after user updates VBA form based on data calculated in a cell

Threaded View

  1. #1
    Registered User
    Join Date
    07-15-2016
    Location
    uk
    MS-Off Ver
    10
    Posts
    1

    Unhappy Trigger message box after user updates VBA form based on data calculated in a cell

    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
    Last edited by alansidman; 07-15-2016 at 08:36 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to make a message box pop up in user form
    By cardonas in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-08-2016, 12:33 PM
  2. Msg box based on cell value from user form entry
    By lacey0519 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-19-2014, 10:42 AM
  3. Replies: 1
    Last Post: 08-28-2013, 05:04 PM
  4. Updates to form elements are not possible if user enters text?
    By Burgos in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-04-2012, 12:56 PM
  5. Image instead of message in User form
    By Tunk Ayauit in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-28-2011, 01:55 PM
  6. Replies: 5
    Last Post: 06-24-2009, 06:36 PM
  7. Message box based on user entry in cell
    By hutch@edge.net in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2008, 04:41 PM

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