Dodgester2
New Member
- Joined
- Nov 14, 2018
- Messages
- 9
Hello group,
Looking for why the following line doesn't work as expected on occasion (probably about 15% of the time)
l_rngCurVerse.Characters(l_lngStartPositionOfOldAnnotation, l_lngLengthOfOldAnnotation).Text = l_strCurrentVerseAnnotation
I can see all of the variables in this particular are returning correct values
l_rngCurVerse is referencing the correct cell
l_lngStartPositionOfOldAnnotation is showing the correct start position
l_lngLengthOfOldAnnotation is showing the correct length of the old annotation text
l_rngCurVerse.Characters(l_lngStartPositionOfOldAnnotation, l_lngLengthOfOldAnnotation).Text is showing the correct text that the line of code is supposed to be replacing
l_strCurrentVerseAnnotation is showing the correct new text that is to be annotated
There is no lock on the cell and the worksheet is not protected, but then this shouldn't be an issue anyhow given this line of code does work about 85% of the time, but it is still frustrating it doesn't work for the other 15% of the time as it also doesn't error out, thus easy to overlook.
What's the purpose of using this code?
Given the format, if I use the plain Find and Replace, it will mess up the format of the cells and that would be a lot of work, thus that's what had me think of this method to overcome that issue.
Why not taking it into something like MS Word?
There's way too many cells with text to do that with, so that's why using VBA seems to be much more simple to do than the copy and paste method others have stated.
Wish I could say I have seen a pattern of what seems to be causing this intermittent issue, but I haven't noticed a pattern. I know, I know, it makes it much harder without that pattern, but then if I would have spotted a pattern, I probably would have been attacking the issue based on that pattern.
Looking for why the following line doesn't work as expected on occasion (probably about 15% of the time)
l_rngCurVerse.Characters(l_lngStartPositionOfOldAnnotation, l_lngLengthOfOldAnnotation).Text = l_strCurrentVerseAnnotation
I can see all of the variables in this particular are returning correct values
l_rngCurVerse is referencing the correct cell
l_lngStartPositionOfOldAnnotation is showing the correct start position
l_lngLengthOfOldAnnotation is showing the correct length of the old annotation text
l_rngCurVerse.Characters(l_lngStartPositionOfOldAnnotation, l_lngLengthOfOldAnnotation).Text is showing the correct text that the line of code is supposed to be replacing
l_strCurrentVerseAnnotation is showing the correct new text that is to be annotated
There is no lock on the cell and the worksheet is not protected, but then this shouldn't be an issue anyhow given this line of code does work about 85% of the time, but it is still frustrating it doesn't work for the other 15% of the time as it also doesn't error out, thus easy to overlook.
What's the purpose of using this code?
Given the format, if I use the plain Find and Replace, it will mess up the format of the cells and that would be a lot of work, thus that's what had me think of this method to overcome that issue.
Why not taking it into something like MS Word?
There's way too many cells with text to do that with, so that's why using VBA seems to be much more simple to do than the copy and paste method others have stated.
Wish I could say I have seen a pattern of what seems to be causing this intermittent issue, but I haven't noticed a pattern. I know, I know, it makes it much harder without that pattern, but then if I would have spotted a pattern, I probably would have been attacking the issue based on that pattern.