+ Reply to Thread
Results 1 to 1 of 1

Compare 2 months in different combobx, msgbox if one comes before the other

Hybrid View

  1. #1
    Registered User
    Join Date
    04-08-2015
    Location
    Belgium
    MS-Off Ver
    Office 2013
    Posts
    51

    Compare 2 months in different combobx, msgbox if one comes before the other

    Hi,

    I've been searching for over 3 hours now to achieve qomething quite simple (or so I thought).

    Attached sheet is an example. In cbomaand1 you need to enter the first month (eg 1 for January).
    In cbomaand2 you enter the second month (eg 9 for September). I will use this to get a list of orders from lthe selected months.

    Now, if cbomaand1 is October (10) and cbomaand 2 is January (1), I want to display a msgbox. of course, when you first start the userform, cbomaand 2 will be blank. If you give cbomaand1 a value, it will result in a msgbox. Therefor, I used this code:

    Private Sub cbomaand1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Call cijfersenmaandena
    
        If cbomaand2.Value <> "" Then
            If cbomaand1.Value > cbomaand2.Value Then
                Cancel = True
                MsgBox "De periode 'van' valt voor de periode 'tot'. Gelieve dit te corrigeren", vbExclamation
                'cbomaand2.SetFocus
                Else
                'nix doen
            End If
            Else
            'nix doen
        End If
        
        
    End Sub
    The problem is, I don't receive a msgbox if both comboxes are filled in and I'm starting to change the months in cbomaand1.
    Could someone please help me out, it's driving me mad...
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] VBA compare sums in ranges and display delta in MsgBox
    By vio.coman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2015, 05:15 AM
  2. Trying to only compare one bar in a bar chart that has multiple months
    By BrookieOU in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 06-10-2015, 07:38 AM
  3. compare two actual months
    By Anto_BT in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-02-2015, 09:29 AM
  4. Compare latest 2 months of data
    By EricBarnes88 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-07-2014, 10:09 PM
  5. [SOLVED] Userform : how to get combobx names in Ascending order
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-08-2014, 09:57 AM
  6. Auto Filter using combobx, coming up a debug
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-05-2014, 02:08 AM
  7. [SOLVED] ComboBox when external value change other combobx return Value
    By feroguz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-14-2013, 04:33 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