View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
John_John John_John is offline
external usenet poster
 
Posts: 40
Default I WANT TO CREATE MANDATORY CELLS

Hi!

You can also try with this code:

Option Explicit
Const cstrMandatory As String = "A:A" 'For column "A" only.
Dim fIsBlank As Boolean
Dim strAddress As String

Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If Not Application.Intersect(.Cells(1), _
Range(cstrMandatory)) Is Nothing Then
fIsBlank = .Value = ""
End If
End With
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Target
If fIsBlank Then
Application.EnableEvents = False
Range(strAddress).Select
MsgBox "This cell required!", vbExclamation
Application.EnableEvents = True
Else
If Not Application.Intersect(.Cells(1), _
Range(cstrMandatory)) Is Nothing Then
If .Count = 1 Then
strAddress = Target.Address
fIsBlank = .Value = ""
End If
End If
End If
End With
End Sub

Creates a "CellTrap" and you can not get out until type something.
Paste this code in code module of your sheet.

Cheers,
John John


Ο χρήστης "LOCK CELLS" *γγραψε:

I WANT TO CREATE MANDATORY CELLS IN WORKSHEET.
IF THE CELLS ARE BLANK THEN NOT ALLOW TO FORWARD.