excel - delete element from variant in vba -
i have variant has list of source
dim source variant source = range("a4:a" & rowcount)
sometimes rowcount
4 in case reassigning source to
source = range("a4:a5")
now want delete last row source(2)/source(2,1)
how can delete it?
i tried erase source
clears everything
i processing data in source , populating few dict items have make changes in many places if source not array since have used each in many places
how can have first element alone or remove last element?
you can't use redim preserve
because 1 cell variant set range in 2d.
use .value
or .value2
proper array , buffer variable erase , transfer in source data :
dim source variant, a() redim a(0) if rowcount<>4 source = range("a4:a" & rowcount).value else source = range("a4:a5").value a(0)=source(1,1) redim source(1 1, 1 1) source(1,1)=a(0) end if
Comments
Post a Comment