2017-09-25 1 views
1

누구든지 내 Excel 문제로 저를 도울 수 있습니까? 텍스트가있는 셀이 있습니다. 이 텍스트의 일부 단어는 굵게 인쇄됩니다. 이러한 단어는 키워드이며 키워드의 식별을 위해 행의 다른 셀에 추가되어야합니다. 예 : 셀의엑셀 추출물 굵은 글씨 텍스트의 단어

텍스트 : 내가 정보

경로에 대한 구글지도를 사용하려면

출력 :

구글; 지도; 노선;

미리 감사드립니다.

답변

3

이 UDF를 사용하여 동일한 결과를 얻을 수도 있습니다. 아래 코드를 모듈에 입력하십시오.

Public Function findAllBold(ByVal rngText As Range) As String 
    Dim theCell As Range 
    Set theCell = rngText.Cells(1, 1) 

    For i = 1 To Len(theCell.Value)  
     If theCell.Characters(i, 1).Font.Bold = True Then   
      If theCell.Characters(i + 1, 1).Text = " " Then 
       theChar = theCell.Characters(i, 1).Text & ", " 
       Else 
       theChar = theCell.Characters(i, 1).Text 
      End If 
      Results = Results & theChar 
     End If 
    Next i 
    findAllBold = Results 
End Function 

새로 생성 된 함수를 사용하여 모든 셀에서 굵은 값을 반환 할 수 있습니다.

enter image description here

+0

이 매크로를 이용해 주셔서 감사합니다. 매력처럼 작동 :-) –

+0

당신은 오신 것을 환영합니다 :) –

3

Option Explicit 

Sub Demo() 

    Dim ws As Worksheet 
    Dim str As String, strBold As String 
    Dim isBold As Boolean 
    Dim cel As Range 
    Dim lastRow As Long, i As Long 

    Set ws = ThisWorkbook.Sheets("Sheet1") 'change Sheet1 to your data sheet 
    isBold = False 

    With ws 
     lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row 'last row with data in Column A 
     For Each cel In .Range("A1:A" & lastRow).Cells  'loop through each cell in Column A 
      strBold = "" 
      For i = 1 To Len(cel.Value) 
       If cel.Characters(Start:=i, Length:=1).Font.Bold = True Then 'check if character is bold 
        isBold = True 
        str = Mid(cel.Value, i, 1) 
        If cel.Characters(Start:=i, Length:=1).Text = " " Then 'check for space 
         strBold = strBold & "; " 
         isBold = False 
        Else 
         strBold = strBold & str 
        End If 

       Else 
        If isBold Then 
         strBold = strBold & "; " 
         isBold = False 
        End If 
       End If 
      Next 
      cel.Offset(0, 1) = strBold 
     Next 
    End With 
End Sub 

enter image description here

here에서이 코드를 유도 해보십시오.

+0

@JensEger - 코드 대담한 공간을 처리하기 위해 업데이트되었습니다. – Mrig

+0

@NikolaosPolygenis - 위 코드를 실행 해 보셨습니까? – Mrig

+0

예, 제대로 작동합니다. theFont.Bold = True). 이전 Font.FontStyle = "Bold"은 cel.Offset (0, 1)에 텍스트를 전달하지 않습니다. –

관련 문제