Results 1 to 14 of 14

mandatory cells

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    546

    mandatory cells

    Hello to all.
    This macro:
    Option Explicit
    
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    Dim cella As Range
    Application.EnableEvents = False
    
    
    Set cella = Cells(Target.Row, 1) '<<< cella singola
    
    With cella
    If .Value = "" Then
    
    'MsgBox "Devi inserire una data nella cella  A" & Target.Row & " ", vbCritical, "Errore!"
    MsgBox "You must enter a date in cell A" & Target.Row & " ", vbCritical, "Errore!"
    
    End If
    
    End With
    
    
    Application.EnableEvents = True
    End Sub
    you must enter a date in cell A mandatory
    Now I added mandatory too column B / C / D but the warning appears 3 times, but it should only appear in the selected cell.
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
    Dim cella As Range
    Application.EnableEvents = False
    
    'Set cella = Range("A3") '<<< cella singola
    'Set cella = Cells(Target.Row, Target.Column) '<<< colonna
    
    Set cella = Cells(Target.Row, 1) '<<< cella singola
    
    With cella
    If .Value = "" Then
    
    'MsgBox "Devi inserire una data nella cella  A" & Target.Row & " ", vbCritical, "Errore!"
    MsgBox "You must enter a date in cell A" & Target.Row & " ", vbCritical, "Errore!"
    
    End If
    
    End With
    
    
    Set cella = Cells(Target.Row, 2) '<<< cella singola
    
    With cella
    If .Value = "" Then
    
    MsgBox "Devi inserire il reparto nella cella  B" & Target.Row & " ", vbCritical, "Errore!"
    
    End If
    
    End With
    
    
    
    Set cella = Cells(Target.Row, 3) '<<< cella singola
    
    With cella
    If .Value = "" Then
    
    MsgBox "Devi inserire l'operatore nella cella  C" & Target.Row & " ", vbCritical, "Errore!"
    
    End If
    
    End With
    
    
    
    Set cella = Cells(Target.Row, 4) '<<< cella singola
    
    With cella
    If .Value = "" Then
    
    MsgBox "Devi inserire il tempo nella cella  D" & Target.Row & " ", vbCritical, "Errore!"
    
    End If
    
    End With
    
    
    
    Application.EnableEvents = True
    End Sub
    you can edit?
    xam
    Attached Files Attached Files
    Last edited by xam99; 01-12-2020 at 04:47 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Mandatory Cells
    By Rich789 in forum Excel General
    Replies: 1
    Last Post: 08-24-2017, 08:33 AM
  2. VBA - mandatory cells in excel
    By bees2cute in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-17-2016, 09:02 AM
  3. How can I make multiple cells mandatory if new rows are used with some cells left blank?
    By markbarnett in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-11-2015, 07:06 AM
  4. Mandatory field required message when user skips mandatory fields
    By Bharathi27 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-11-2013, 05:12 AM
  5. Mandatory Cells
    By MYQ in forum Excel General
    Replies: 7
    Last Post: 10-12-2012, 02:16 PM
  6. Mandatory cells
    By john.mk in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 02-25-2010, 11:03 PM
  7. Mandatory Cells
    By Mel1221 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-05-2006, 05:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1