Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Pop-Up alert in Excel

Posted on 2011-02-25
6
Medium Priority
?
598 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 30

Accepted Solution

by:
SiddharthRout earned 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

670 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