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
 

Some videos you may like

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

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?
 

Watch MrExcel Video

Forum statistics

Threads
1,122,181
Messages
5,594,720
Members
413,926
Latest member
andycap

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