Why did I get this ERROR? - Criteria Expression

ChrisOK

Well-known Member
Joined
Mar 26, 2003
Messages
599
Does anyone know why this error occurs when it hits this line of code?
Code:
Range("M5").PasteSpecial Paste:=xlPasteValues

"Run-time error '-2147217913(80040e07)':
Data type mismatch in criteria expression.


Here's the full code:
Code:
Sub MOD_35BBB_UNDHIDE_ALL_COLUMNS_AND_ROWS_PASTE_SPECIAL_DATA_SAVE()
'
' UNDHIDE_ALL_COLUMNS_AND_ROWS Macro
' UNHIDES ALL THE COLUMNS AND ROWS THAT WERE HIDDEN FROM A THROUGH AG
' The range of a thru g can be changed if need to use this macro with a different file

'
    Columns("A:AM").Select
    Range("AM1").Activate
    Selection.EntireColumn.Hidden = False
    ActiveWindow.ScrollColumn = 15
    ActiveWindow.ScrollColumn = 14
    ActiveWindow.ScrollColumn = 13
    ActiveWindow.ScrollColumn = 12
    ActiveWindow.ScrollColumn = 11
    ActiveWindow.ScrollColumn = 10
    ActiveWindow.ScrollColumn = 9
    ActiveWindow.ScrollColumn = 8
    ActiveWindow.ScrollColumn = 7
    ActiveWindow.ScrollColumn = 6
    ActiveWindow.ScrollColumn = 5
    ActiveWindow.ScrollColumn = 4
    ActiveWindow.ScrollColumn = 3
    ActiveWindow.ScrollColumn = 2
    ActiveWindow.ScrollColumn = 1
    ActiveSheet.Range("$A$4:$A$5000").AutoFilter Field:=1
    Range("A1").Select
    
'-------------------------------------------------------------
  'THE BELOW SECTION COPY>PASTE SPECIALS THE DATA THAT WAS IN FORMULA FUNCTION FORMAT INTO OTHER COLUMNS AS NEEDED
    
    Range("AI5:AI" & Range("AI" & Rows.Count).End(xlUp).Row).Copy
    Range("O5").PasteSpecial Paste:=xlPasteValues


    Range("AJ5:AJ" & Range("AJ" & Rows.Count).End(xlUp).Row).Copy
    Range("M5").PasteSpecial Paste:=xlPasteValues


    Range("AM5:AM" & Range("AM" & Rows.Count).End(xlUp).Row).Copy
    Range("T5").PasteSpecial Paste:=xlPasteValues
    

    
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Jerry Sullivan

MrExcel MVP
Joined
Mar 18, 2010
Messages
8,787
Hi Chris,

I'm not seeing anything in that code itself that would cause that error message.

"Data type mismatch in criteria expression" is usually associated with a query is trying to apply a criteria to a field of a different type.

Do you have a query in your workbook? If so, does it use parameters from the worksheet that might be getting changed by your paste operation?
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,023
Messages
5,856,868
Members
431,837
Latest member
megantang

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