vba - Selecting rows in one column on the basis of a selected range -


i trying write macro formatting cells on basis of range selected in column. here want select rows in column b on basis of selected range in column a, i.e., want select portion in column b column has value. when run gives error "type mismatch"

i used code purpose:

sub macro2() dim lr long dim n long lr = range("a" & rows.count).end(xldown).row n = range("a1:a" & lr).specialcells(xlcelltypeconstants) range("b1:b" & n).select end sub 

i new in vba. appreciated.

thank you

your problem on line

n = range("a1:a" & lr).specialcells(xlcelltypeconstants) 

you have declared n long, specialcells returns range. not sure how fix this, can't tell trying do. first attempt

dim rng range set rng = range("a1:a" & lr).specialcells(xlcelltypeconstants) 

this should fix error.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -