How to use VBA to select the first iterm in a drop down list in Excel -
i used data validation create drop down lists. know how use vba select first iterm in drop down list?
i tried 'splite' funciton:
cell.value = split(cell.validation.formula1, ",")(0) but did not work well, work if put "option1, option2" in source in data validation window. if refer source range of options, return errors.
i guess there should smarter ways.
thanks!
sub test() dim adr string range("c4") adr = mid(.validation.formula1, 2) debug.print range(adr).cells(1, 1) end end sub so answer is:
set c = range("c4")
c.value = range(mid(c.validation.formula1, 2)).cells(1, 1).value
Comments
Post a Comment