If you need to concatenate serious amounts of text (i.e >100000 bytes) together and you're using the regular & or + VBA concatenation operator you'll find that performance can be increased dramatically by using the little known mid$ statement. Here's what the HELP on mid says:
Replaces a specified number of characters in a Variant (String) variable with characters from another string.
Syntax
Mid(stringvar, start[, length]) = string
The Mid statement syntax has these parts:
Part Description
stringvar Required. Name of string variable to
modify.
start Required; Variant (Long). Character
position in stringvar where the
replacement of text begins.
length Optional; Variant (Long). Number of
characters to replace. If omitted, all of
string is used.
string Required. String expression that replaces
part of stringvar.
Remarks
The number of characters replaced is always less than or equal to the number of characters in stringvar.
So say I have a string variable 'data_block' with 900000 characters in it and I want to concatenate another string with 100000 characters onto it - say 'data_line'. Here's how you do it with mid
' make sure our data_block variable can accommodate 1000000 characters
' and our data_line can take 100000
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.