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

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,303
Office Version
  1. 365
Platform
  1. Windows
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.
 

kemperohlmeyer

Board Regular
Joined
Oct 4, 2006
Messages
73
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
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,303
Office Version
  1. 365
Platform
  1. Windows
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
 

Forum statistics

Threads
1,141,400
Messages
5,706,217
Members
421,433
Latest member
yash0468

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
Top