Broken Excel VBA Macro Run-time error '1004': Method 'Range' of object '_Global' failed -
i have macro, called "hide completed", has worked since april. macro supposed put items in order completion date hide rows have data in date completed field. reason, failed last week , haven't been able determine went wrong. identical macro running on tab (different names tables , field names), , works fine. haven't found threads on stack overflow (or other site) close enough problem of assistance. here's macro:
sub hidecompleted() ' ' showcompleted macro ' application.screenupdating = false ' range("a1").select activesheet.listobjects("table2").range.autofilter field:=1 ' sortdatabydate macro ' activeworkbook.worksheets("project list").listobjects("table2").sort.sortfields.clear activeworkbook.worksheets("project list").listobjects("table2").sort.sortfields.add _ key:=range("table2[[#all],[complete" & chr(10) & "date]]"), sorton:=xlsortonvalues, _ order:=xlascending, dataoption:=xlsorttextasnumbers activeworkbook.worksheets("project list").listobjects("table1").sort .header = xlyes .matchcase = false .orientation = xltoptobottom .sortmethod = xlpinyin .apply end ' ' hidecompleted macro ' ' range("a2").select activesheet.listobjects("table2").range.autofilter field:=1, criteria1:="=" application.screenupdating = true end sub
excel calling attention to: run-time error '1004': method 'range' of object '_global' failed.
but highlighted code in debugger is:
i have checked number of characters in individual cells see if i'm on 911 character limit (especially cells in comment column - column f). isn't case. i'm attaching image of excel worksheet give idea how used. appreciated.
if problem think is, many other answers resolve it.
the parameter you've provided key
argument not qualified, implicitly doing:
activeworkbook.worksheets("project list").listobjects("table2").sort.sortfields.add _ key:=activesheet.range("table2[[#all],[complete" & chr(10) & "date]]"), sorton:=xlsortonvalues, _ order:=xlascending, dataoption:=xlsorttextasnumbers
of course fail if activesheet sheet other "project list"
@ run-time.
resolve qualifying range object appropriate worksheet:
dim wsprojectlist worksheet set wsprojectlist = activeworkbook.worksheets("project list") wsprojectlist.listobjects("table2").sort.sortfields.add _ key:=wsprojectlist.range("table2[[#all],[complete" & chr(10) & "date]]"), _ sorton:=xlsortonvalues, _ order:=xlascending, dataoption:=xlsorttextasnumbers
Comments
Post a Comment