excel - VBA Code not working Universally -


i'm trying write universal code can esentially can copy , paste of reports (they're identical reports, need run every day). it's formatting , deleting report of uncessary data. when wrote code worked when paste workbook runs ok. still format , assign special values things won't delete values don't want! know why is?

here's code (mind might not efficient method of coding, i'm mere novice :) )

sub newfilter() dim wbi workbook, wb0 workbook dim wsi worksheet, ws0 worksheet dim myrange range dim outputrange range, endorange dim nfrange range dim long, j long   'establish source of info worbooks , worksheet set wbi = thisworkbook set wsi = wbi.sheets("sheet1")  'filters original wb criteria 'selection.autofilter activesheet.range("a1").autofilter field:=5, criteria1:=array( _     "gur insurance plan 1", "gur insurance plan 2", "gur insurance plan 3", _     "gur insurance plan 4", "gur insurance pol no 1", "gur insurance pol no 2", _     "gur insurance pol no 3"), operator:=xlfiltervalues  'establish , create new worbook output info set wb0 = workbooks.add  wb0  'save new workbook set ws0 = wb0.sheets("sheet1") .saveas filename:="new soarian test"  'copy visible cells in original workbook wsi.cells.copy  'paste values , formatting rules new workbook ws0.range("a1").pastespecial paste:=xlvalues, operation:=xlnone, _     skipblanks:=false, transpose:=false ws0.range("a1").pastespecial paste:=xlpasteformats, operation:=xlnone, _     skipblanks:=false, transpose:=false end  'add new column called "rep" ws0.columns("a:a").insert shift:=xltoright,         copyorigin:=xlformatfromleftorabove ws0.range("a1").value = "rep"  **'filter soarian column "approved" selection.autofilter ws0.range("a1").autofilter field:=7, criteria1:=array( _      "approved"), operator:=xlfiltervalues if ws0.range("e1:e1000").specialcells(xlcelltypevisible).rows.count > 1 then**  'select , delete cells unfilter ws0.range("a2:i1000").specialcells(xlcelltypevisible).select application.displayalerts = false selection.delete application.displayalerts = true ws0.autofiltermode = false  else  ws0.autofiltermode = false  end if  **'filter encprov clincal psych , physcial therapy ws0.range("a1").autofilter field:=3, criteria1:=array( _      "physical therapy", "clinic psych outpat"), operator:=xlfiltervalues  if ws0.range("c1:c1000").specialcells(xlcelltypevisible).rows.count > 1 'select visible cells , delete them , unfilter ws0.range("a2:i1000").specialcells(xlcelltypevisible).select application.displayalerts = false selection.delete application.displayalerts = true else ws0.autofiltermode = false end if** 

esentially i'm having trouble getting "approved" , clinical therapy , physical therapy values delete when filter them. works in original workbook wrote code in. ideas??

thank much!


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -