Hi
Within a code I need to add a certain character into an existing string a specific number of times.
As example:
Let’s say I want to add a certain amount of 2’s into a string
The number of 2’s to be added is held in a Number variable, NumberOf2sIWant
So let’s say I need 4 x 2’s, so NumberOf2sIWant = 4
So for example, if my existing string start is_...
Give me some 2s please here:
_...and the end bit is
.I thank you kindly.
_... then I need finally
Give me some 2s please here: 2222 .I thank you kindly.
_......
I have only been able to figure out one way to do it in Excel VBA as in the code below. That seems too complicated to me, and is not much use to me as I need it in VBA Word. Ideally a code that worked in both Excel and Word VBA would be even better.
Can anyone help?
Thanks
Alan
P.s.
I guess a workaround is to get VBA Excel code to work in Word so as to use my code.
I will look into that now, I think it can be done. But maybe that is getting messy and unnecessarily complicated ?
I know Excel VBA fairly well, but not much Word VBA.
Code that works in Excel VBA ( It is the Evaluate(" ") Function that does not appear to be available in VBA Word – reasonable I suppose as it is to do with doing spreadsheet things )
_...........................![]()
Please Login or Register to view this content.
Edit:
OK, that was not too difficult, but very messy:
I would still prefer to do it simpler , if that is possible.., thanks![]()
Please Login or Register to view this content.
Bookmarks