I have a spreadsheet where users input a number of data items. It then checks to see how many of these are duplicated across the last 10 days within the spreadsheet and then flags these on a scale and informs the user with flags if they are duplicated and need to be checked.
The table (List Object) has a date in the 1st Column (A) - TODAY() of a spreadsheet auto populates so the user doesn't need to input it.... which is set to auto filter on the last 10 days worth of data.
1) If the user deletes the date by mistake then the code bugs out as the calculations fail..
- Is there a way to protect column A as part of the list object, to stop the user deleting the date and making the code bug out!?
- Is there are way to set conditional formatting of Column A as the date that will allow the auto filtering to be maintained...? Seems to conflict between two date formats when i try this!
Also looking to change the range of Today Date from being one dimensional Today() to Today()+1, but can deal with one thing at a time if i get the 1st bit solved!! DOnt want walk before i can crawl!!
I have attached some of the code snippets, not all of the code as there's quite a lot, attaching the spreadsheet isn't an option i'm afraid , any help would be greatly appreciated, this is very frustrating!
Thanks
Code: Select all
Private Sub Worksheet_Change(ByVal Target As Range)
' Switch Screen Off
With Application
.DisplayAlerts = False
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
Dim EmptyCount As Variant
Dim EmptyCells As Range
Dim LastRow As Variant
Dim Calc_Status As String
Dim ActiveCellRow As Variant
Dim ActiveCellCol As Variant
Dim Amber_Cr As Variant
Dim Red_Cr As Variant
Dim tDate As String
Dim fDate As String
LastRow = ""
EmptyCount = ""
ActiveCellRow = ""
ActiveCellCol = ""
Calc_Status = ""
' Stores last cell
ActiveCellRow = ActiveCell.row
ActiveCellCol = ActiveCell.Column
' Calculate Last_Row Named Range on Control Sheet
Worksheets("Controls").Range("Last_Row").Calculate
LastRow = Sheets("Controls").Evaluate("Last_Row")
Calc_Status = Sheets("Controls").Evaluate("Full_Calc")
EmptyCount = Application.WorksheetFunction.CountBlank(Range("Change_Area"))
If EmptyCount = 0 Then
' Make Sure Date is present First Column
Dim DateCheck As Variant
Dim DateValue As Date
DateValue = Sheets("Controls").Evaluate("TodayDate")
DateCheck = Sheets("book1").Evaluate("Date_Check")
If DateCheck = "" Then
Sheets("book1").Cells(LastRow, 1).Value = DateValue
Cells(LastRow, 1).NumberFormat = "dd/mm/yyyy"
End If
Worksheets("Controls").Calculate
With Application
.DisplayAlerts = False
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
' Delete any Conditional Formatting Applied to Sheet
Cells.FormatConditions.Delete
' Apply Conditional Formatting
Code: Select all
Worksheets("book1").Activate
tDate = Sheets("Controls").Evaluate("First_Row_Date")
fDate = Format(tDate, "yyyy/mm/dd")
Worksheets("book1").ListObjects("book1_TABLE").Range.AutoFilter
Field:=1, Criteria1 :="=" , Operator:=xlor, Criteria2:=">=" & fdate