excel vba - Vba Cell Selection Based on Value -
i couldn't find asking quite looking for...
i using 2 conditions set selection (finding value "reducer", in cell directly below it, finding "" {an empty cell}).
i having trouble finding way select cells match these criteria , listing cell address (i want display cell address in message box, alerting them of location of 'error')
eventually there many more cells for, why want search through multiple cells.
so in nutshell, want code find 2 criteria, select cell matching criteria, , show pop-up message stating cell error in.
private sub worksheet_change(byval target range) if activesheet.range("j11").value < 0 msgbox "you have exceeded maximum allowable pipe length section. please review selection before continuing. ", vbokonly, "inoperable pipe length" end if while activesheet.range("j17,j7").value = "reducer" if activesheet.range("j18,j8").value = "" g = sheets("pipe calcs").range("j18,j8").address msgbox "please select reducer size in cell " & g & activecell.address(false, false), vbcritical, "no reducer size selected" exit sub else end end if loop end sub
private sub worksheet_change(byval target range) if activesheet.range("a1").value < 0 msgbox "you have exceeded maximum allowable pipe length section. please review selection before continuing. ", vbokonly, "inoperable pipe length" end if each cell in range("j1:j1000") if cell.value = "reducer" if range(cell.address).offset(1, 0) = "" g = sheets("pipe calcs").range(cell.address).offset(1, 0).address msgbox "please select reducer size in cell " & g range(cell.address).offset(1, 0).select exit sub end if end if next end sub
the above code check column j
"reducer", if found, see if cell below contains value, if doesn't prompt user cell , exit sub. when user updates cell, trigger worksheet_change
statement , cause macro run again.
Comments
Post a Comment