+ Reply to Thread
Results 1 to 3 of 3

VB Autofilter causing run-time error 438

  1. #1
    Registered User
    Join Date
    11-12-2017
    Location
    Stafford, England
    MS-Off Ver
    365
    Posts
    184

    VB Autofilter causing run-time error 438

    Hi,

    I'm running Microsoft 365 at home and using Office 2016 at work, I have no admin rights at work so record macro's etc are locked.

    Problem I have is my workbook works fine at home and does exactly what I what but I get a 'run-time error 438 object doesn't support' message when I run it at work.

    Attached is the workbook but due to sensitive data it is unpopulated.

    Clicking the buttons in blue should paste data, sort it and print the 'Print List' tab.

    The modules that contain the error and the sort commands are 5 & 6 and when click debug the error that shows in yellow is

    HTML Code: 
    To my knowledge VBA hasn't changed so why would this not work?

    TIA
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    06-20-2021
    Location
    UK
    MS-Off Ver
    2016
    Posts
    126

    Re: VB Autofilter causing run-time error 438

    • Paste() procedure: PasteSurname -> paste from where? What is it copying exactly?
    • Adding call keyword to procedures is not needed anymore. It is redundant (refer to link at bottom of this post).
    • I would also organise a bit more for readability like so:


    Please Login or Register  to view this content.
    Your error basically says the object property or method not supported. I would focus on Key:= argument in your sortfields method as that can often be the culprit.

    Try: set rng=Range("J:J") alongside Dim rng as Range in your problematic modules: 5 and 6?

    I would also refer to this on using Call - https://bettersolutions.com/vba/macr...ll-keyword.htm
    Last edited by immigrated4urjob; 09-20-2021 at 07:19 PM.

  3. #3
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent SAC
    Posts
    8,885

    Re: VB Autofilter causing run-time error 438

    Use Add not Add2

    It's most likely just different versions of Excel.
    Rory

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Userform with listboxes for autofilter causing Error 1004
    By sknalodz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-19-2020, 11:40 PM
  2. [SOLVED] This line of code is causing an error message "Autofilter method of range class failed"
    By hadleedog in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-04-2018, 03:58 AM
  3. Run-Time 32809 Error causing havok - what's a workaround?
    By luger in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-15-2015, 11:47 AM
  4. [SOLVED] Run time error 1004 - why is the last line of this code causing this?
    By SweetSorcery in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 07-14-2014, 06:57 AM
  5. VBA Code...error = run time error 1004 autofilter method of range class failed
    By Dariusd7 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-15-2013, 04:49 PM
  6. [SOLVED] getElementsByClassName from Yammer causing Run-time error 91
    By gerainta in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-20-2013, 05:49 AM
  7. File SaveAs causing run-time error
    By c4tin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-14-2009, 12:34 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1