ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Message box warning of missing data (https://www.excelbanter.com/excel-programming/440504-message-box-warning-missing-data.html)

Jock

Message box warning of missing data
 
Hi,
When a user inputs data (numbers) into cells in column D, they should
include a three digit prefix before the numbers. I would like a message box
to pop up if they fail to do this and delete what they have put in the cell
thus forcing them to try again. For example 09/123 would be rejected but
SUM09/123 would be ok.

Thanks in advance.
--
Traa Dy Liooar

Jock

Jacob Skaria

Message box warning of missing data
 
Select the sheet tab which you want to work with. Right click the sheet tab
and click on 'View Code'. This will launch VBE. Paste the below code to the
right blank portion. Get back to to workbook and try out.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 And Target.Count = 1 And Target.Text < "" Then
If Not Target.Text Like "[A-Z][A-Z][A-Z]#*" Then
Target = "": Target.Select
'Msbgox "Display a message"
End If
End If
End Sub

--
Jacob


"Jock" wrote:

Hi,
When a user inputs data (numbers) into cells in column D, they should
include a three digit prefix before the numbers. I would like a message box
to pop up if they fail to do this and delete what they have put in the cell
thus forcing them to try again. For example 09/123 would be rejected but
SUM09/123 would be ok.

Thanks in advance.
--
Traa Dy Liooar

Jock



All times are GMT +1. The time now is 11:45 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com