0

I created a system of sheets for my employment office which organize volunteer information and schedules, and separates the schedules by month. When I want to add a new month, I have a macro that copies a "master" sheet for the month from the "master" workbook to all of the 47 different sheets. On four of these sheets, the below code crashes. On the remaining 43 it works just fine.

sourceBook.Sheets(Array("February, "Events", "Volunteers")).Copy _ After:=destinationBook.Sheets("Volunteers")

The code inside the with also crashes the same sheets, but not the others.

With sourceBook.Sheets("February").UsedRange destinationBook.Sheets("February").Range("A1").Resize( _ .Rows.Count, .Columns.Count) = .Formula End With

On all sheets, the February sheet does not exist, and Events and Volunteers do. The code later deletes the duplicates. Why would Excel crash on only some of them (they seem to be identical at surface level) for this copy? If you need additional information, I'll supply it.

3
  • Would looping through a generated list of sheet names be a better option instead of addressing a sheet that does not exist and do you have any error trapping?
    – Solar Mike
    Jan 20, 2019 at 6:01
  • Is there something different about the sheet code names of the "problem" workbooks compared to the workbooks which show no errors? Jan 20, 2019 at 7:41
  • The different workbooks all have names that come from a table of language names. I am a relatively new VBA user and don't know what sort of error trapping would be recommended.
    – Caledrith
    Feb 1, 2019 at 19:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.