PeterBaileyUk
asked on
add character in correct position in vba
I have two words
hilux
hi-lux
I have ascertained the position of the hyphen in StringWords2(index2) how do i insert that hyphen into the same position in StringWords1(index)?
I have previously determined that removal of the hyphen would lead to a match of words.
but I want to insert and not remove it.
hilux
hi-lux
I have ascertained the position of the hyphen in StringWords2(index2) how do i insert that hyphen into the same position in StringWords1(index)?
I have previously determined that removal of the hyphen would lead to a match of words.
but I want to insert and not remove it.
'traverse array and compare the words
For index = LBound(StringWords1()) To UBound(StringWords1())
For index2 = LBound(StringWords2()) To UBound(StringWords2())
If Replace(StringWords2(index2), "-", "") = StringWords1(index) Then
hypenPos = InStr(1, StringWords2(index2), "-", vbTextCompare)
Else
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
was a spelling mistake all working
ASKER
thank u
NP. Glad to help = )
ASKER
StringWords1(index) = Mid(StringWords1(index), 1, hyphenPos - 1) & "-" & Mid(StringWords1(index), hyphenPos)