Ive been working on a bit of VBA code for a while now but I cant seem to get it to work.
What i want tit to do is to look for a file and create one if it doesnt exist but at the same time for it to be able to be used in any file location.
this is what ive got so far:
Sub findfile()
Dim filepath As String
filepath = ThisWorkbook.Path & "\Registers\Register " & Range("C3")
If Dir(ThisWorkbook.Path & "\Registers\Register " & Range("C3")) <> "" Then
MsgBox "File exists"
Exit Sub
Else
Call AddWorkbook
End If
End Sub
Sub AddWorkbook()
Workbooks.Add
ChDir ThisWorkbook.Path & "\Registers"
ActiveWorkbook.SaveAs Filename:= _
ThisWorkbook.Path & "\Registers\Register 2013.xlsx" _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWindow.Close
End Sub
Any help would be much appreciated
Thanks
Moderator's Note: You have to put code tags around your codes.Thank you.
Bookmarks