Solved

Excel IF statement pop-up dialog box VBA

Posted on 2011-03-14
2
533 Views
Last Modified: 2012-05-11
Hello,

I have a spreadsheet where a user enters numbers into column G.  

I would like to use a VBA script that will make a dialogue box pop-up if a number entered into a cell in column G is less than the number directly above it.

Any help is greatly appreciated.
0
Comment
Question by:evanmarshall
2 Comments
 
LVL 24

Accepted Solution

by:
StephenJR earned 500 total points
ID: 35131884
Try this in the sheet module - right-click the sheet tab, View Code and paste this in:
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column <> 7 Then Exit Sub

If IsNumeric(Target.Value) And IsNumeric(Target.Offset(-1).Value) And Target.Value < Target.Offset(-1).Value Then
    MsgBox "Less than"
End If

End Sub

Open in new window

0
 

Author Closing Comment

by:evanmarshall
ID: 35132659
Excellent.  Thank you!
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

This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

707 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

19 Experts available now in Live!

Get 1:1 Help Now