How to make match() work with date in excel vba? -


i'm having problem making match() work in excel vba. code is:

x = application.match("sep 2008", range("f1:f1"), 0) 

the value in cell f1 9/1/2008.

even if changed sep 2008 9/1/2008, still doesn't return value.

any idea how fix it?

your best bet use .find(). return range if found or nothing if not.

set x = range("f1:f1").find(cdate("sept 2008"), , , xlwhole) 

if wanted column number:

x = range("f1:f1").find(cdate("sept 2008"), , , xlwhole).column 

with capture of not found

sub test()      dim y date, x variant, c long     y = cdate("sep 2008")     set x = range("1:1").find(y, , , xlwhole)     if not x nothing         c = x.column '<~~found     else         exit sub 'not found     end if  end sub 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -