excel vba - VBA run time error 1004 in VBA, application defined or object definned error -


i getting error raised above on piece of code reuse regularly. cannot life of me figure out issue is. error occur @ line:

ws4.range("f2:f" & lastrow).formula = "=if(d2="", e2, d2)" 

then lastrow variable working , ws4 defined. lost.

thanks

try in empty excel sheet:

option explicit  public sub test()      dim lastrow     long     dim rngcell     range      lastrow = 5      each rngcell in activesheet.range("f2:f" & lastrow)         rngcell.formular1c1 = "=if(1=1,2,3)"     next rngcell  end sub 

then try see differences between , code. can not referring correct sheet or else. sheet can locked (e.g. 1004 well). or cells can locked. thus, looping can you.


Comments

Popular posts from this blog

Ansible warning on jinja2 braces on when -

Parsing a protocol message from Go by Java -

html - How to custom Bootstrap grid height? -