I need to accomplish the following with very little VBA experience!!
Click on a cell that contains a date
Check to see if a file exists using the selected date, "C:\Users\Jeff\OneDrive\LH\Events and Conference Points Table\date"
If it does open it
If it doesn't, create it from a template "C:\Users\Jeff\OneDrive\LH\Events and Conference Points Table Template" and save it as a new file with the date at the end in the LH folder
If another date is clicked while this workbook is still open, save and close this workbook before opening the newly selected date.
This is what I tried:
Click on a cell that contains a date
Check to see if a file exists using the selected date, "C:\Users\Jeff\OneDrive\LH\Events and Conference Points Table\date"
If it does open it
If it doesn't, create it from a template "C:\Users\Jeff\OneDrive\LH\Events and Conference Points Table Template" and save it as a new file with the date at the end in the LH folder
If another date is clicked while this workbook is still open, save and close this workbook before opening the newly selected date.
This is what I tried:
Code:
Sub File_Exists()
Dim FileName As String
FileName = VBA.FileSystem.Dir("C:\Users\Jeff\OneDrive\LH\Events and Conference Points Table" & Target.Value)
If FileName = VBA.Constants.vbNullString Then
Workbooks.Open "C:\Users\Jeff\OneDrive\LH\Events and Conference Points Table.xls"
ThisWorkbook.SaveCopyAs "C:\Users\Jeff\OneDrive\LH\Events and Conference Points Table\" & Target.Value
Else
'Update the path to a valid path on your PC
Workbooks.Open "C:\Users\Jeff\OneDrive\LH\Events and Conference Points Table" & Target.Value
End If
End Sub