Why did I get this ERROR? - Criteria Expression

ChrisOK

Well-known Member
Joined
Mar 26, 2003
Messages
601
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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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?
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,730
Members
448,987
Latest member
marion_davis

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