To change text in a selected range to proper case use this code.
Sub ProperCase()
Dim cell As Range
For Each cell In Selection.Cells
If cell.HasFormula = False Then
cell = strconv(cell.text,vbProperCase)
End If
Next
End Sub
To delete import error tables from database
Sub deleteimporterrors()
Dim tbldef As TableDef
For Each tbldef In CurrentDb.TableDefs
If tbldef.name Like "*_importerror*" Then
DoCmd.DeleteObject acTable, tbldef.name
End If
Next tbldef
End Sub
Dim tbldef As TableDef
For Each tbldef In CurrentDb.TableDefs
If tbldef.name Like "*_importerror*" Then
DoCmd.DeleteObject acTable, tbldef.name
End If
Next tbldef
End Sub
To Capture Last modified date of the file
If you want to capture last modified date of any file, you can use below code.
Sub test()
Dim fso As Object, myDir As String, fn As String, myFile As String, myDate As Date, maxDate As Date
Set fso = CreateObject("Scripting.FileSystemObject")
myDir = "C:\temp"
fn = Dir(myDir & "\*.csv)
Do While fn <> ""
myDate = fso.GetFile(myDir & "\" & fn).DateLastModified
If maxDate < myDate Then
myFile = fn
maxDate = myDate
End If
fn = Dir()
Loop
MsgBox myDir & "\" & fn & " : " & maxDate
End Sub
Sub test()
Dim fso As Object, myDir As String, fn As String, myFile As String, myDate As Date, maxDate As Date
Set fso = CreateObject("Scripting.FileSystemObject")
myDir = "C:\temp"
fn = Dir(myDir & "\*.csv)
Do While fn <> ""
myDate = fso.GetFile(myDir & "\" & fn).DateLastModified
If maxDate < myDate Then
myFile = fn
maxDate = myDate
End If
fn = Dir()
Loop
MsgBox myDir & "\" & fn & " : " & maxDate
End Sub