2016-08-26 1 views
0

vba에서 분할 기능을 사용하여 밑줄이 그어진 단어를 기반으로 셀을 분할하는 방법이 있습니까? 구분 기호를 밑줄로 어떻게 설정할 수 있습니까?밑줄이 그어진 단어의 셀 분할

d = Trim(cell.Value2) 
arr = Split(d, " ") 
+2

아니요. 밑줄은 외관상의 기능이며 분할 기능에 전달할 수있는 문자열은 모두 문자열입니다. – cyboashu

+0

감사합니다. @cyboashu. 당신은 대답에 그것을 넣을 수있어서 받아 들일 수 있습니다. – johndoe253

+0

괜찮습니다. 하지만 밑줄 친 문자 나 밑줄 친 단어로 분리해야합니까? – cyboashu

답변

2

여기에는 하나의 접근 방법이 있습니다. 범위를 처리하는 오류가 많이 있지만 이것이 올바른 방향으로 설정해 줄 것입니다.

eTest을 넣어 또는 기타 문자는 테스트 A1 밑줄.

Public Function getArray(rng As Range) 

    Dim arr() 

    Dim lCtr  As Long 
    Dim strText  As String 
    Dim strDelim As String 

    '/ Create a delim which is qunique, so you dont miss any data. 
    strDelim = "!!_<{>}##" 

    For lCtr = 1 To rng.Characters.Count 

     If rng.Characters(lCtr, 1).Font.Underline = XlUnderlineStyle.xlUnderlineStyleSingle Then 
      '/ Splits exluding the underlined char 
      strText = strText & strDelim 

      '/ Splits including the underlined char 
      'strText = strText & rng.Characters(lCtr, 1).Text & strDelim 

     Else 
      strText = strText & rng.Characters(lCtr, 1).Text 
     End If 

    Next 

    getArray = Split(strText, strDelim) 



End Function 


Sub test() 
    MsgBox getArray(Cells(1, 1))(0) 
End Sub 
+1

도움을 청합니다. – johndoe253

관련 문제