Solved

Pop-Up alert in Excel

Posted on 2011-02-25
6
572 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to strip out formula but retain value in cell 2 25
Getting rid of #VALUE! 7 23
Need convert a number to 8 27
Excel 2010 - SUMIF with and AND 2 5
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

820 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