Results 1 to 9 of 9

How to keep data validation error message shownWhen copy and paste value fromAnother file?

Threaded View

  1. #1
    Registered User
    Join Date
    08-12-2016
    Location
    DC, USA
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    22

    How to keep data validation error message shownWhen copy and paste value fromAnother file?

    I have a spreadsheet with lots of columns with drop-down menus from data validation. When someone enters a value different than one of the values from the drop-down menu, Excel will show an error message saying the input has to be as the same as one of the drop-down menu choices. This works well when people type a value to a cell. However, if they copy and paste a value from another spreadsheet, the error message is not shown. For example, for Current Status (column J) in the attached spreadsheet, there are three answer choices from the drop-down menu: Still active, Graduated, and Left without graduation. When I copied and pasted the text "Unknown" from another spreadsheet to J4, no error message is shown. I know that J4 will be circled if I click Circle Invalid Data under Data Validation. However, I want something that will force update of J4. Is there a way to keep the original validation when people copy and paste?

    BTW, I have the code below under VBA and I need the code to still function after making the error message shown.

    Thank you very much in advance!




    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Dim rngCell As Range, strBlanks As String
    
        strBlanks = vbNullString
        For Each rngCell In Sheet1.Range("B2:B238").Cells
            If Len(Trim(rngCell.Value)) > 0 Then
                If WorksheetFunction.CountA(rngCell.Offset(0, 2).Resize(1, 2)) < 2 Then
                    strBlanks = strBlanks & IIf(Len(strBlanks) > 0, ",", "") & Replace(rngCell.Offset(0, 2).Resize(1, 2).SpecialCells(xlCellTypeBlanks).Address, "$", "")
                End If
                
                If rngCell.Offset(0, 5).Value = "" Then
                    strBlanks = strBlanks & IIf(Len(strBlanks) > 0, ",", "") & Replace(rngCell.Offset(0, 5).Address, "$", "")
                End If
                           
                
                If WorksheetFunction.CountA(rngCell.Offset(0, 7).Resize(1, 3)) < 3 Then
                    strBlanks = strBlanks & IIf(Len(strBlanks) > 0, ",", "") & Replace(rngCell.Offset(0, 7).Resize(1, 3).SpecialCells(xlCellTypeBlanks).Address, "$", "")
                End If
                
                
                If rngCell.Offset(0, 8).Value = "Graduated" Then
                    If rngCell.Offset(0, 11).Value = "" Then
                       strBlanks = strBlanks & IIf(Len(strBlanks) > 0, ",", "") & Replace(rngCell.Offset(0, 11).Address, "$", "")
                    End If
                End If
                
                If rngCell.Offset(0, 8).Value = "Left without Graduation" Then
                    If rngCell.Offset(0, 11).Value = "" Then
                       strBlanks = strBlanks & IIf(Len(strBlanks) > 0, ",", "") & Replace(rngCell.Offset(0, 11).Address, "$", "")
                    End If
                End If
                
                If rngCell.Offset(0, 8).Value = "Graduated" Then
                    If rngCell.Offset(0, 14).Value = "" Then
                       strBlanks = strBlanks & IIf(Len(strBlanks) > 0, ",", "") & Replace(rngCell.Offset(0, 14).Address, "$", "")
                    End If
                End If
                
                If rngCell.Offset(0, 14).Value = "Other, specify" Then
                   If rngCell.Offset(0, 15).Value = "" Then
                       strBlanks = strBlanks & IIf(Len(strBlanks) > 0, ",", "") & Replace(rngCell.Offset(0, 15).Address, "$", "")
                   End If
                End If
    
                
                
                
            End If
        
    
        Next rngCell
    
        If Not strBlanks = vbNullString Then
            MsgBox "Entries Required In Cells " & vbCrLf & vbCrLf & strBlanks
            Cancel = True
            Exit Sub
        End If
        
        
        
    End Sub
    Attached Files Attached Files
    Last edited by yl41012; 08-19-2016 at 04:46 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Data Validation Error Message
    By Yoepy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-21-2015, 10:28 PM
  2. User Opens File - Copy and paste data from sheet - 400 error
    By cheeze83 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-10-2015, 09:37 AM
  3. Replies: 0
    Last Post: 05-20-2013, 05:17 PM
  4. error message when Automating copy/paste worksheets
    By curbster in forum Excel Programming / VBA / Macros
    Replies: 35
    Last Post: 10-29-2009, 08:06 PM
  5. Error message when someone paste over Data Validation cells
    By m.cain in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-14-2007, 06:11 PM
  6. Too stupid for copy/paste? Error message
    By dune2 in forum Excel General
    Replies: 3
    Last Post: 11-27-2006, 11:54 AM
  7. [SOLVED] Data Validation fromanother sheet
    By tonto57 in forum Excel General
    Replies: 1
    Last Post: 03-21-2006, 08:30 AM

Tags for this Thread

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