Link to home
Start Free TrialLog in
Avatar of PeterBaileyUk
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.

'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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PeterBaileyUk
PeterBaileyUk

ASKER

I get an invalid procedure call on:

StringWords1(index) = Mid(StringWords1(index), 1, hyphenPos - 1) & "-" & Mid(StringWords1(index), hyphenPos)
was a spelling mistake all working
thank u
NP. Glad to help  = )