excel - Application defined or object defined error on code -
excel - Application defined or object defined error on code -
i error on line in code, ideas issue may be?
intersect(.usedrange, .usedrange.offset(1)).specialcells(12).entirerow.delete
here rest of code:
sub definedl_idl() dim wbthmacro workbook, wsregulares worksheet, wsregularesdemitidos worksheet, wstempactivos worksheet, _ wstempja worksheet, wstempfit worksheet, wstempdemitidos worksheet, wsps worksheet, wsresultados worksheet, _ wsdllist worksheet, wssheet worksheet, count_dl integer, count_idl integer dim x&, r long '*************regulares*********** sheets("regulares").select 'debug.print xltoright 'sheets("raw").copy before:=sheets(2) sheets("regulares") '.name = "final2" .usedrange.autofilter 9, "inative" intersect(.usedrange, .usedrange.offset(1)).specialcells(12).entirerow.delete r = worksheetfunction.counta(.range("a:a")) .usedrange.autofilter .range("j:j").insert xltoright .range("j1").value = "real mo" .range("k:k").cut .range("i:i").insert xltoright .range("q:q").cut .range("i:i").insert xltoright .range("l2:l" & r).formular1c1 = "=vlookup(rc[-3],'dl list'!c[-11]:c[-10],2,0)" .range("l2:l" & r).value = .range("l2:l" & r).value x = 2 r if range("l" & x).text = "#n/a" 'if range("k" & x).value = "dl" ' range("l" & x).value = "dl" 'else: range("l" & x).value = "idl": end if range("l" & x).value = "idl" end if next x end count_dl = application.worksheetfunction.countif(activesheet.range("l:l"), "dl") count_idl = application.worksheetfunction.countif(activesheet.range("l:l"), "idl") worksheets("resultados").range("b17") = count_dl worksheets("resultados").range("c17") = count_idl
your look works on test worksheet problem must data.
i not stringing properties because objective becomes unclear. worse, if fails, not know fails.
try replacing statement this:
dim rng range debug.print .usedrange.address debug.print .usedrange.offset(1).address set rng = intersect(.usedrange, .usedrange.offset(1)) debug.print rng.address debug.print rng.specialcells(12).address debug.print rng.specialcells(12).entirerow.address rng.specialcells(12).entirerow.delete
step through code create sure each range expect.
my guess that there no visible cells in range attempting delete nothing
.
edit info finding lastly row of worksheet.
there variety of methods of finding lastly used row or column of worksheet. none work in every situation usedrange
method to the lowest degree give result expect.
the popular method of finding lastly row, judging answers here, is:
rowlast = .cells(rows.count,9).end(xlup).row
this vba equivalent of placing cursor in bottom cell of column 9 , clicking ctrl+up. rowlast
set lastly row value in column 9 unless have value in bottom cell. method of use, there must value in specified column of lastly used row.
find
reliable method of finding lastly value either row or column.
specialcells
useful method.
this reply of mine vba dynamic ranges includea macro, findfinal
, demonstrates how these methods can fail give result might expect. if wish understand issues, step through macro studying happens.
excel vba excel-vba
Comments
Post a Comment