Results 1 to 5 of 5

Data validation on multiple sheets.

Threaded View

  1. #1
    Forum Contributor
    Join Date
    05-20-2013
    Location
    Ann Arbor, MI
    MS-Off Ver
    Excel 2010
    Posts
    255

    Data validation on multiple sheets.

    Hello,

    I'm currently using this code:
    If Not Application.Intersect(Target, Range("B1:E100")) Is Nothing Then
        If Range("B" & Target.Row) = "" And Range("C" & Target.Row) = "" And Range("D" & Target.Row) = "" And Range("E" & Target.Row) = "" Then
            Range("A" & Target.Validation).Delete
        Else
            With Range("A" & Target.Row).Validation
                .Delete
                .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                xlBetween, Formula1:= _
                "=IF(NOT(AND(B" & Target.Row & "="""",C" & Target.Row & "="""",D" & Target.Row & "="""",E" & Target.Row & "="""")),Priority,"""")"
            End With
        End If
     End If
    to insert data validation on entries in a spreadsheet.

    I then use a variation of this code to transfer entries from one sheet to the other, and perhaps back again:
    Private Sub UpdateHistory1_Click()
    
     Dim xlRng As Range
        
        On Error GoTo UpdateHistory1_Click_ErrorHandler
    
        If ActiveSheet.ProtectContents Then
            MsgBox "Sheet protected! Please select the, 'Edit Sheet' button, and" & _
                " enter the password before this button can be used.", vbOKOnly + vbInformation, "Update History"
            GoTo UpdateHistory1_Click_Proc_Exit
        End If
    
        Application.ScreenUpdating = False
        
        Dim ws As Worksheet, ms As Worksheet
        Set ws = Sheets("Current Maintenance") 'Current worksheet
        Set ms = Sheets("History Maintenance") 'History
            
        With ms
            .Unprotect "123steel"
            
            'heading:
            .Range(.Cells(6, 1), .Cells(6, 8)).Value = Array("Priority", _
                                                             "Today's Date", _
                                                             "Equipment", _
                                                             "Location", _
                                                             "Description", _
                                                             "Expected Time of Completion", _
                                                             "Completed? y or n", _
                                                             "Time of Completion")
        
            End With
            
            With ws.ListObjects("Table1").Range
            
                .AutoFilter 7, "y" 'finds y in 7th column (G)
                If .Columns(1).SpecialCells(xlCellTypeVisible).Cells.Count > 1 Then
                   .Resize(.Rows.Count - 1).Offset(1).SpecialCells(xlCellTypeVisible).Copy
                   ms.Cells(ms.Cells(ms.Rows.Count, 2).End(xlUp).Row + 1, 1).PasteSpecial Paste:=xlPasteValues
                   .Resize(.Rows.Count - 1).Offset(1).EntireRow.Delete Shift:=xlUp
                End If
                .AutoFilter
                
            End With
            
    UpdateHistory1_Click_Proc_Exit:
        On Error GoTo 0
        If Not ActiveSheet.ProtectContents Then ActiveSheet.Protect "123steel"
        Application.ScreenUpdating = True
        Exit Sub
    UpdateHistory1_Click_ErrorHandler:
        MsgBox "Error: " & Err.Number & " (" & Err.Description & ") in Sub 'UpdateHistory1_Click' of VBA Document 'Sheet11'.", vbOKOnly + vbCritical, "Error"
        Resume UpdateHistory1_Click_Proc_Exit
        
    End Sub
    If I take an entry, move it to a different sheet, and decide I want to move that entry back to its original sheet, how can I return the data validation back to the cell?

    I have attached my workbook.
    The password, when prompted, is "MillSteel"

    I want data validation to only be present on "Current ____" sheet. not "History ___"
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

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