Offset + match with a variable vba -


i'm trying use variable in offset() , match() function. doesn't work.

for each valid_type in valid_sec_type_range  'test = valid_sec_type_range.cells(1, valid_type_index).value 'test1 = chr(34) & valid_type & chr(34)  new_range = [offset(market_value_range,match(valid_type,sec_type,0)-1,0,countif(sec_type,valid_type),1)] 

and when use works, seems function match , offset not recognize valid_type string.

for each valid_type in valid_sec_type_range  'test = valid_sec_type_range.cells(1, valid_type_index).value 'test1 = chr(34) & valid_type & chr(34)  new_range = [offset(market_value_range,match("asset backed",sec_type,0)-1,0,countif(sec_type,"asset backed"),1)] 

new_range = [offset(...)] syntactic sugar this:

new_range.value = application.evaluate("[offset(...)]") 

so yes, variable name understood literal string, understood range name, , don't have range of name.

if using vba, in vba way:

new_range.value = market_value_range.offset(application.worksheetfunction.match(valid_type.value, sec_type, 0) - 1, 0).resize(application.worksheetfunction.countif(sec_type, valid_type.value), 1) 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -