Check if a spreadsheet exists and if not, create it

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,352
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I tried to copy code off the net and modify it but it didn't work. I am trying to see if a folder and file exists and if not, create it.

This is what I wrote.
VBA Code:
Sub TestSheetCreate()
    Dim newSheetName As String
    Dim checkSheetName As String
    newSheetName = ThisWorkbook.Path & "\Young People\list.xlsm"
    On Error Resume Next
    checkSheetName = Worksheets(newSheetName).Name
    If checkSheetName = "" Then
        Worksheets.Add.SaveAs = newSheetName
        MsgBox "The sheet named ''" & newSheetName & _
        "'' does not exist in this workbook but it has been created now.", _
        vbInformation
         
    Else
        MsgBox "The sheet named ''" & newSheetName & _
        "''exist in this workbook.", vbInformation
    End If
End Sub

It needs to look for List.xlsm in a folder called "Young People" in the current directory and if it doesn't exist, create it.

Can someone help me with the above code as it doesn't work please?
 
Patience Dave......
without seeing the other codes, try
VBA Code:
Set f = wbList.shList.Range("A:A").Find(newyp, xlValues, xlWhole)
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Thanks Michael, what other Code do you need to see?
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top