excel - Select range based on 3 relative references -
i have big file, need select range delimited 3 points in order export it; references 2 column headers defined, , lastly cell situated before first blank in column. 2 column headers, "w" , "z", in row 5, "w" can in cell ax , w in cell ay, no fixed distance between ax , ay.
your help much appreciated!
edit - triying add together more detail can´t add together pictures:
let´s i´ve 2 columns care first:
the first 1 left, 1 contains header "w", , other, 1 contains header "z".
i don´t know if there 20 or 234 columns in middle, if that´s case, need select of them, they´re betweeen limits.
if there´s more info beyond column labeled "z", don´t care. this, i´ve weidht.
now, height, need check column "yy", between "w" , "z", , go downwards lastly consecutive value has - let´s phone call "e" (that means if we´ve blank cell in column, don´t care anymore other values below).
so, height go row contains label, 1 contains value "e".
if want defined range, using start row, start col, , end row, end col...
' assumes first row includes header ' = start row ' b = start col, finds w match ' c = lastly row of info ' d = lastly col = 5 b = application.worksheetfunction.match("w",range("5:5"),0)) d = application.worksheetfunction.match("z",range("5:5"),0)) ' c = lastly row of data.... ' version uses end(xldown) aka ctrl-down arrow yy header in row c = cells(a, application.worksheetfunction.match("yy",range("5:5"),0)).end(xldown).row '' or '' c = application.worksheetfunction.match("yy",range("5:5"),0)) ' col '' c = application.worksheetfunction.match("e",cells(5,c).entirecolumn,0)) ' row in col matches e assuming dont want go way downwards '' or - loop '' = '' while cells(i,application.worksheetfunction.match("yy",range("5:5"),0)) <> "" '' = + 1 '' loop '' c = - 1 yourrange = range(cells(a,b),cells(c,d)) alternatively, can utilize intersect, above should work rough start. suggest specifying sheet referenced. , doing checks error catching ensure w, z , yy exists, , column w > column yy > column z
excel vba excel-vba
No comments:
Post a Comment