excel - How to skip over a section of code if two cells don't equal a certain value? -


i'm making macro copies data between multiple workbooks. section of code needs run in specific situation. problem is, whether or not code run, code after need run. example:

' if range("b26").value <> "#n/a" , range("d26").value <> "#n/a" ' ' transfers component data '     range("b28").select     selection.copy     windows("form.xls").activate     range("o61:p61").select     activesheet.paste     range("i71:j71").select     activecell.formular1c1 = "10.00%"     range("a72:p72").select     range("a1:a21").select     windows("transfer template.xlsm").activate     range("a1").select  end if  ' ' final_transfer_macro macro '     range("b1").select     selection.copy     windows("form.xls").activate     range("f7:i7").select     selection.pastespecial paste:=xlpastevaluesandnumberformats, operation:=         xlnone, skipblanks:=false, transpose:=false     range("a1:a21").select     windows("transfer template.xlsm").activate     range("a1").select 

the 'transfers component data' section part won't run. before , after run.

also, don't care if .select slow, or .activate not ideal. please don't lecture me.

adjust code using section won't run (in if statement) between if , end if so:

if condition     transfers component code (if condition true) end if  code 

if not working (the transfers component executed) problem condition statement(s) - true

edit:

just did little search , check n/a need 2 condition checks. 1 check if there error in value of cell , check if equal

if not (iserror(range("b26").value) , iserror(range("d26").value))     if range("b26").value <> cverr(xlerrna) , range("d26").value <> cverr(xlerrna)         transfers code here     end if end if 

source


Comments