Solved

Pop-Up alert in Excel

Posted on 2011-02-25
6
563 Views
Last Modified: 2012-05-11
Is it possible to create a pop-up in excel if a certain cell doesn't contain a value if a certain other cell contains a value?
Let's say
Cell A1 is called "Sales", Cell A2 in called Man hours. Sales is entered to Cell B1, man hours to cell B2. What I want is a pop up alert if Cell B2 is empty if Cell B1 contains a value.
0
Comment
Question by:Brasch
  • 4
  • 2
6 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34985328
Is this what you want?

Sample Attached. Enter a value in B1 and it will promt like you wanted.

Code Used

Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    If Not Intersect(Target, Range("B1")) Is Nothing Then
        If Len(Trim(Target.Value)) <> 0 Then
            If Len(Trim(Target.Offset(1).Value)) = 0 Then _
            MsgBox "Please input man hours"
        End If
    End If
    Application.EnableEvents = True
End Sub

Open in new window

Sample.xls
0
 

Author Comment

by:Brasch
ID: 34985358
That would probably do, but quite annoying in the long run - these things are only invented for people not filling out the forms - for the ones actually doing it right that would be very annoying. If possibly (I have no idea if it is) the perfect solution would be a pop-up when saving. A polite reminder, but when not entering info, it should be a concious choice. Still not being able to save anyway would be a bug. I see how the message is changed, but the best would be "Are you sure you want to continuing without entering man hours?" upon saving
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34985365
1) Instead of showing a popup, use a comment.
2)  Do you want to disable save if one of them is empty?

Sid
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
ID: 34985388
Here is an example. Upon Saving the file It will prompt if one of them is filled and the other is empty and it won't allow you to save the file till the time both are empty or both are filled. I am also using comments so the users don't get annoyed.

Code Used

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    If Not Len(Trim(Sheets("temp").Range("B1").Value)) = 0 And _
    Len(Trim(Sheets("temp").Range("B2").Value)) = 0 Then
        MsgBox "Please fill the Sales/Man hours"
        Cancel = True
    End If
End Sub

Open in new window


Sid
Sample.xls
0
 

Author Comment

by:Brasch
ID: 34985409
As far as I know comments are "onMouseOver", that wouldn't work for an alert

Disabling save would be a bad choice, since both the sales and man hours are based on computer systems and they tend to break down now & then - still sales could be entered after closing and saved before everybody stops working, hence man hours are still ticking. An alert upon saving would be the best, but your first example could work if that's not possible, this is a simplified example, so it would have to be modified to come up with more alerts based upon the same cell
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34985431
As far as I know comments are "onMouseOver", that wouldn't work for an alert

Not necessarily. You can show them permanently.

An alert upon saving would be the best, but your first example could work if that's not possible,

If that is the case then delete the line "Cancel = True" and it will let you save after showing the POP UP

Sid
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now