I have VBA code in a workbook that copies some columns from a sheet and pastes them a few columns to the right on the same sheet. Then, another sub is called that makes a copy of a shape (text box) on that sheet. Everything was working great yesterday.
Today when I tried it, I received a run-time error.
In addition, there was a message in the bottom left of the Excel window.
If I clicked Don't show again, closed the Excel file, then tried again, the message would pop up again.
I have never seen the Clipboard error message before.
The first thing I tried was rebooting my computer. That didn't solve it. Still happened the next time I can the code.
I looked online and tried several things, but no luck.
Here's the sub that is trying to copy the shape. You'll see the various things I've tried.
The error is happening on this line:
The columns & shape need to be copied on multiple sheets, so the code to copy the columns will run for one sheet, and then this sub will run for that same sheet. That process repeats multiple times via a For loop. The first time it runs (the sheet is named "A"), it works. It's on the second time around (the sheet is named "B") that it causes the error. I even had one time where it got to the third sheet (named "C") when the error occurred.
Again, this worked fine yesterday, so I don't have any idea what has suddenly happened to cause this. I'd appreciate any help, as I'm at a total loss.
Today when I tried it, I received a run-time error.
In addition, there was a message in the bottom left of the Excel window.
If I clicked Don't show again, closed the Excel file, then tried again, the message would pop up again.
I have never seen the Clipboard error message before.
The first thing I tried was rebooting my computer. That didn't solve it. Still happened the next time I can the code.
I looked online and tried several things, but no luck.
Here's the sub that is trying to copy the shape. You'll see the various things I've tried.
VBA Code:
Sub CreateMainButton(SN As String, FirstPhaseID As Integer, NewID As Integer)
Dim PhaseName As String
With ThisWorkbook.Sheets(SN)
'I have added these lines to try to avoid the clipboard error.
.Activate
Application.CutCopyMode = False
.Range("A1").Copy
Application.CutCopyMode = False
Application.DisplayAlerts = False
'This copies the button for Phase1.
.Shapes("bt_main_Phase" & FirstPhaseID).Copy
.Paste
Application.DisplayAlerts = True
Application.CutCopyMode = False
End With
End Sub
The error is happening on this line:
VBA Code:
.Shapes("bt_main_Phase" & FirstPhaseID).Copy
The columns & shape need to be copied on multiple sheets, so the code to copy the columns will run for one sheet, and then this sub will run for that same sheet. That process repeats multiple times via a For loop. The first time it runs (the sheet is named "A"), it works. It's on the second time around (the sheet is named "B") that it causes the error. I even had one time where it got to the third sheet (named "C") when the error occurred.
Again, this worked fine yesterday, so I don't have any idea what has suddenly happened to cause this. I'd appreciate any help, as I'm at a total loss.