Hi All,
Long time lurker first time poster here, relatively new to VBA. I have a workbook with a series of sheets that I would like to copy (all except the first) into a different book while also replacing any sheets with the same name in the destination workbook.
Is it possible to have a macro look at the name of the sheets in my source workbook then replace any sheets in the destination workbook if the same name exists, with any new sheets just being copied over ?
I currently have some code used to open the destination workbook, but struggle with the process above
Any help or advice is much appreciated.
Long time lurker first time poster here, relatively new to VBA. I have a workbook with a series of sheets that I would like to copy (all except the first) into a different book while also replacing any sheets with the same name in the destination workbook.
Is it possible to have a macro look at the name of the sheets in my source workbook then replace any sheets in the destination workbook if the same name exists, with any new sheets just being copied over ?
I currently have some code used to open the destination workbook, but struggle with the process above
Code:
Sub CopyReplaceWorksheets()
Dim strDestPath As String
Dim strFileDest As String
Dim strSourcePath As String
Dim strSourceFile As String
strDestPath = Range("A1").Value
strFileDest = Range("A2").Value
strSourcePath = Range("A3").Value
strSourceFile = Range("A4").Value
info = IsWorkbookOpen(strDestPath)
If info = True Then
MsgBox "File is being used"
Else
MsgBox "File is closed"
End If
If info = False Then
Workbooks.Open strDestPath
End If
Any help or advice is much appreciated.