Ok, below is the code that goes out and gets the data from the specified files. When it goes to the "Code" sheet and gets the name of the sheet, I would like it to also make sure the modified date is proper. Imagine if the name is mistyped, it will error out. I want that same effect if the modified date is different than what is selected.
For instance, if I select "Cabinettttt1.xlsx", but the actual file name is "Cabinet1.xlsx", it will error out. I want that same affect to happen if the file has been modified from the date that I specify. So if I program the file name to be "Cabinet1.xlsx 12/2/2011 8:33 pm" and the actual file has been modified and resaved as "Cabinet1.xlsx 1/1/2012 1:00 am", it will error out because the names do not match.
Sub ComboBoxSelectCabinetStyle()
Application.ScreenUpdating = False
lcWorkbookName = ActiveWorkbook.Name
Application.DisplayAlerts = False
ActiveSheet.Unprotect
Set myDocument = ActiveSheet
lcmyMasterDocument = ActiveSheet.Name
lcCodeSheet = "Code"
Sheets(lcCodeSheet).Visible = True 'Unhide code sheet
Sheets(lcCodeSheet).Select
Range("c4").Select 'The name of the source file
lcSheetName = Selection.Value
Range("a8").Select
lcFQPath = Selection.Value 'Variable for where the source files are kept
ActiveWindow.SelectedSheets.Visible = False 'Hide code sheet
Sheets(lcmyMasterDocument).Select
vbWhyNot = MsgBox("Overwrite Data? with data from " & lcSheetName, vbYesNo)
If vbWhyNot = 6 Then
'For Each sh In myDocument.Shapes
' If Left(sh.Name, 4) = "Pict" Then
' sh.Delete
' End If
'Next
With ActiveSheet
AutoFilterMode = False
Range("A11:H500").AutoFilter
Visibledropdown = False
Range("A11:H499").AutoFilter Field:=1, Visibledropdown:=False
Range("A11:H499").AutoFilter Field:=2, Visibledropdown:=False
Range("A11:H499").AutoFilter Field:=3, Visibledropdown:=False
Range("A11:H499").AutoFilter Field:=4, Visibledropdown:=False
Range("A11:H499").AutoFilter Field:=5, Visibledropdown:=False
Range("A11:H499").AutoFilter Field:=6, Visibledropdown:=False
Range("A11:H499").AutoFilter Field:=7, Visibledropdown:=False
Range("A11:H499").AutoFilter Field:=8, Visibledropdown:=False
End With
ChDir lcFQPath
lcFQPathAndFile = lcFQPath & lcSheetName
Workbooks.Open FileName:=lcFQPathAndFile, Notify:=False 'Activate the source file
lcSourceBookName = ActiveWorkbook.Name
Range("A12:L500").Select
Application.CutCopyMode = False
Selection.Copy
Windows(lcWorkbookName).Activate
Application.ScreenUpdating = False
Sheets(lcmyMasterDocument).Select
Range("a12:L500").Select
ActiveSheet.Paste
ChDir lcFQPath
lcFQPathAndFile = lcFQPath & lcSheetName
Workbooks.Open FileName:=lcFQPathAndFile, Notify:=False 'Reactivate the source file
ActiveWindow.Close
End If
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Range("a12").Value = "."
ActiveSheet.Protect
ActiveCell.Offset(-6, 2).Select
Bookmarks