quick troubleshoot

kemperohlmeyer

Board Regular
Joined
Oct 4, 2006
Messages
73
For some reason this sub won't run. It returns a "type mismatch error". The debugger claims that the line with "****" in front of it is the error. Please help.

ko

Sub CopyPasteTest()
Dim sht As Worksheet
ThisWorkbook.Sheets("CopySheet").Cells.Copy
For Each sht In ThisWorkbook.Worksheets
If sht.Name <> "Procedure" And sht.Name <> "Manager List" And sht.Name <> "CopySheet" Then
****ThisWorkbook.Sheets(sht).Range("A1").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, skipblanks:=True, Transpose:=False
End If
Next sht
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
The code looks fine to me.:)

The only thing I can think of is that you might have some chart sheets in your workbook.

EDIT: sht is declared as a Worksheet, Sheets expects a string.
 
Upvote 0
Norie, thank you for taking the time to look over it. What exactly do you mean by "chart sheets"?

If anyone else has any thoughts please let me know.

Thanks!
ko
 
Upvote 0
A chart sheet is a created when you create a chart and select As new sheet on the 4th step.

But that isn't your actual problem, see my edit and try this.
Code:
Sub CopyPasteTest()
Dim sht As Worksheet
    ThisWorkbook.Sheets("CopySheet").Cells.Copy
    For Each sht In ThisWorkbook.Worksheets
        If sht.Name <> "Procedure" And sht.Name <> "Manager List" And sht.Name <> "CopySheet" Then
            sht.Range("A1").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, skipblanks:=True, Transpose:=False
        End If
    Next sht
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,998
Members
448,539
Latest member
alex78

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