excel - How to use VBA to execute a macro based on an IF statement? -
i want run excel vba code (all delete specific cells within same row , i've turned on relative reference can apply excel vba code rows, if there's appropriate "x") based on whether there x in cell.
here's i've tried far (the excel vba code called "biology"):
if range("c22").value = "x" call macro_biology end if
i should add i'm writing under vba section "getatplabel". said, total noob, think i'm close, appreciated.
it sounds if important biology (or macro_biology) macro needs know row supposed work on. can pass information across parameter. example:
sub start_with_this() dim rw long, lr long activesheet lr = .cells(rows.count, "c").end(xlup).row rw = 2 lr if ucase(.cells(rw, "c").value) = "x" call macro_biology(rw) end if next rw end end sub sub macro_biology(r long) ' r row passed in. ' r end sub
after starting start_with_this
macro, goes through each cell in column c row 2 last row in it. if finds x or x (case-sensitivity removed forcing cell value upper case before comparing) calls second macro, macro_biology
, tells row deal with.
Comments
Post a Comment