How to delete a row that contains a certain code in the first column using excel VBA? -
i run report weekly , step must take delete row contains phrase, in case "cfs-ghost-djkt", in column a. rows read through start @ 7 , have variable end.
i have looked online , according have found following code should work , error , not line cells(lrow,"a")
i believe far deleteing part goes ok way written problem selection aspect.
firstrow = 7 lastrow = cells(rows.count, "a").end(xlup).row cells(lrow, "a") if not iserror(.value) if .value = "cfs-ghost-djkt" .entirerow.delete end if end
as per narrative ("i must ... delete a row") seem bother 1 occurrence of phrase "cfs-ghost-djkt"
in case there's no need iterating through cells try finding and, if successful, delete entire row
dim f range set f = range("a7", cells(rows.count, "a").end(xlup)).find(what:="cfs-ghost-djkt", lookin:=xlvalues, lookat:=xlpart) if not f nothing f.entirerow.delete
Comments
Post a Comment