Solved

Pop-Up alert in Excel

Posted on 2011-02-25
6
558 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
Comment Utility
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
Comment Utility
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
Comment Utility
1) Instead of showing a popup, use a comment.
2)  Do you want to disable save if one of them is empty?

Sid
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

772 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

12 Experts available now in Live!

Get 1:1 Help Now