简体   繁体   中英

Calculated values used in formula by macro

I am trying to join many (300+) cells many (100+) times, and believe macro is probably the best way of achieving this.

The internet has suggested using concantenate trickery to achieve this:

=CONCANTENATE(B2:B400) and press F9 whilst highlighting the array, and remove the curly brackets.

This works wonderfully if done by a person. However whilst recording the macro, excel decides to insert the values (ie =CONCANTENATE("a", "b", "c")) rather than the trickery. Is there a way around this? I've thought of using sendkeys but, for obvious reasons, I'd rather not.

Or is it better to forego this method entirely and use some sort of loop to join them all together?

Thanks for your help!

Lukas

solution via an UDF

public function concatrange(r)
s=""
for each c in r
s=s & c
next
concatrange=s
end function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM