메인 컨텐츠로 가기

Excel에서 셀의 첫 번째 줄 또는 첫 번째 단어 만 굵게 표시하는 방법은 무엇입니까?

Excel 워크 시트에는 Alt + Enter 키로 단락 된 여러 줄이 포함 된 셀이 많이있을 수 있습니다. 경우에 따라 이러한 셀의 첫 번째 줄만 굵게 표시해야 할 수 있습니다. 또는 세포에서 눈에 띄게 만드는 첫 단어 만 굵게 표시하십시오. 이 기사에서는이를 달성하는 두 가지 방법을 자세히 설명합니다.

VBA 코드로 셀의 첫 번째 줄만 굵게 표시 VBA 코드로 셀의 첫 번째 단어 만 굵게 표시


VBA 코드로 셀의 첫 번째 줄만 굵게 표시

다음 VBA 코드를 사용하면 선택한 셀의 첫 번째 줄만 빠르게 굵게 표시 할 수 있습니다. 다음과 같이하십시오.

1. 프레스 다른 + F11 동시에 열려면 키 응용 프로그램 용 Microsoft Visual Basic 창.

2. 에서 응용 프로그램 용 Microsoft Visual Basic 창을 클릭합니다 끼워 넣다 > 모듈. 그런 다음 아래 VBA 코드를 복사하여 모듈 창에 붙여 넣으십시오.

VBA 코드 : 셀의 첫 번째 줄만 굵게 표시

Option Explicit
Sub BoldFirstLine()
Dim xRng As Range, xCell As Range
Dim xFirstRow As String
On Error Resume Next
Set xRng = Application.InputBox("Please select range:", "Kutools for", Selection.Address, , , , , 8)
If xRng Is Nothing Then Exit Sub
On Error Resume Next
For Each xCell In xRng
    With xCell
        .Characters(1, InStr(.Value, Chr(10))).Font.Bold = True
    End With
Next
End Sub

3. 누르세요 F5 코드를 실행하는 키입니다. 그 다음에 Excel 용 Kutools 대화 상자가 나타나면 굵게 표시해야하는 첫 번째 줄의 범위를 선택한 다음 OK 버튼을 클릭합니다.

그런 다음 아래 스크린 샷과 같이 선택한 셀의 모든 첫 번째 줄이 즉시 굵게 표시되는 것을 볼 수 있습니다.


VBA 코드로 셀의 첫 번째 단어 만 굵게 표시

아래 스크린 샷과 같이 Excel에서 A2 : A4 범위의 첫 단어 만 굵게 표시해야하는 경우가 있습니다. 단계별로 다음과 같이 달성 할 수 있습니다.

1. 프레스 다른 + F11 동시에 열려면 키 응용 프로그램 용 Microsoft Visual Basic 창.

2. 에서 응용 프로그램 용 Microsoft Visual Basic 창을 클릭합니다 끼워 넣다 > 모듈. 그런 다음 아래 VBA 코드를 복사하여 모듈 창에 붙여 넣으십시오.

VBA 코드 : 셀의 첫 번째 단어 만 굵게 표시

Sub boldtext()
Dim xRng As Range, xCell As Range
On Error Resume Next
Set xRng = Application.InputBox("Please select range:", "Kutools fro Excel", Selection.Address, , , , , 8)
If xRng Is Nothing Then Exit Sub
On Error Resume Next
For Each xCell In xRng
  If xCell.Value <> "" Then
    xCell.Characters(1, InStr(1, xCell.Value, " ") - 1).Font.Bold = True
  End If
Next
End Sub

3. 누르세요 F5 코드를 실행하는 키입니다. 팝업에서 Excel 용 Kutools 대화 상자에서 첫 번째 단어를 굵게 만들 범위를 선택한 다음 OK 단추. 스크린 샷보기 :

그런 다음 아래 스크린 샷과 같이 선택한 셀의 모든 첫 단어가 즉시 굵게 표시되는 것을 볼 수 있습니다.


관련 기사:

최고의 사무 생산성 도구

🤖 Kutools AI 보좌관: 다음을 기반으로 데이터 분석을 혁신합니다. 지능형 실행   |  코드 생성  |  사용자 정의 수식 만들기  |  데이터 분석 및 차트 생성  |  Kutools 기능 호출...
인기 기능: 중복 항목 찾기, 강조 표시 또는 식별   |  빈 행 삭제   |  데이터 손실 없이 열이나 셀 결합   |   수식없이 반올림 ...
슈퍼 조회: 다중 기준 VLookup    다중 값 VLookup  |   여러 시트에 걸친 VLookup   |   퍼지 조회 ....
고급 드롭다운 목록: 드롭다운 목록을 빠르게 생성   |  종속 드롭다운 목록   |  다중 선택 드롭 다운 목록 ....
열 관리자: 특정 개수의 열 추가  |  열 이동  |  Toggle 숨겨진 열의 가시성 상태  |  범위 및 열 비교 ...
특색 지어진 특징: 그리드 포커스   |  디자인보기   |   큰 수식 바    통합 문서 및 시트 관리자   |  리소스 라이브러리 (자동 텍스트)   |  날짜 선택기   |  워크 시트 결합   |  셀 암호화/해독    목록으로 이메일 보내기   |  슈퍼 필터   |   특수 필터 (굵게/기울임꼴/취소선 필터링...) ...
상위 15개 도구 세트12 본문 도구 (텍스트 추가, 문자 제거,...)   |   50+ 거래차트 유형 (Gantt 차트,...)   |   40+ 실용 방식 (생일을 기준으로 나이 계산,...)   |   19 삽입 도구 (QR 코드 삽입, 경로에서 그림 삽입,...)   |   12 매출 상승 도구 (숫자를 단어로, 환율,...)   |   7 병합 및 분할 도구 (고급 결합 행, 셀 분할,...)   |   ... 그리고 더

Excel용 Kutools로 Excel 기술을 강화하고 이전과는 전혀 다른 효율성을 경험해 보세요. Excel용 Kutools는 생산성을 높이고 시간을 절약하기 위해 300개 이상의 고급 기능을 제공합니다.  가장 필요한 기능을 얻으려면 여기를 클릭하십시오...

상품 설명


Office Tab은 Office에 탭 인터페이스를 제공하여 작업을 훨씬 쉽게 만듭니다.

  • Word, Excel, PowerPoint에서 탭 편집 및 읽기 사용, Publisher, Access, Visio 및 Project.
  • 새 창이 아닌 동일한 창의 새 탭에서 여러 문서를 열고 만듭니다.
  • 생산성을 50% 높이고 매일 수백 번의 마우스 클릭을 줄입니다!
Comments (11)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
Thank you! Works perfect.
This comment was minimized by the moderator on the site
Hello,

How to bold only the Last line of the cell?
This comment was minimized by the moderator on the site
Hi Spulber,
The following VBA code can help you bold only the last line of each cell in the selected range.
Please note that if a cell has only one line (i.e., no line breaks), then the entire cell content will be bolded. If a cell is empty or contains only numerical values, this subroutine will not affect it.

Option Explicit
'Updated by Extendoffice 20230721
Sub BoldLastLine()
    Dim xRng As Range, xCell As Range
    Dim xLastLineStart As Long
    Dim xTextLength As Long
    
    On Error Resume Next
    Set xRng = Application.InputBox("Please select range:", "Kutools for Excel", Selection.Address, , , , , 8)
    
    If xRng Is Nothing Then Exit Sub
    On Error GoTo 0
    
    For Each xCell In xRng
        With xCell
            xTextLength = Len(.Value)
            xLastLineStart = InStrRev(.Value, Chr(10)) + 1
            If xLastLineStart > xTextLength Then xLastLineStart = 1
            .Characters(xLastLineStart, xTextLength).Font.Bold = True
        End With
    Next
End Sub
This comment was minimized by the moderator on the site
This is fantastic, thanks so much!
Rated 5 out of 5
This comment was minimized by the moderator on the site
Hi. I have many cells that contain multiple lines which were paragraphed by Alt+Enter. I would like to bold and change the color of the first word of each line. Can you help please?
This comment was minimized by the moderator on the site
Hi I have quite a few lines in a cell . I want for make 5th line as bold and italics in a cell . The below code makes only the first line . Can you help

Sub bold()


Dim r As Range, c As Range
Dim ws As Worksheet

Set ws = ActiveSheet
Set r = ws.Range("Y:Y")
For Each c In r
With c
.Font.bold = False
.Value = .Text
.Characters(1, InStr(.Text, vbLf) - 1).Font.bold = True
End With

Next c


End Sub
This comment was minimized by the moderator on the site
How about if I want the second line to be bold?
This comment was minimized by the moderator on the site
Good Day!
If you want to bold only the second line of the cell, please try the following VBA code:

Sub BoldSecondLine()
Dim xRng As Range, xCell As Range
Dim xArr
On Error Resume Next
Set xRng = Application.InputBox("Please select range:", "Kutools for", Selection.Address, , , , , 8)
If xRng Is Nothing Then Exit Sub
For Each xCell In xRng
If xCell <> "" Then
With xCell
xArr = Split(xCell, Chr(10))
.Characters(InStr(.Value, Chr(10)) + 1, Len(xArr(1))).Font.Bold = True
End With
End If
Next
End Sub
This comment was minimized by the moderator on the site
Hi, How about if I want the first three words to be bold?
This comment was minimized by the moderator on the site
Good Day,
Please try below VBA script.

Sub boldtext()
Dim xRng As Range, xCell As Range
Dim xNum As Long, xCount As Long
Dim I As Long, J As Long
Dim xArr
Dim xArrChr10
On Error Resume Next
Set xRng = Application.InputBox("Please select range:", "Kutools fro Excel", Selection.Address, , , , , 8)
If xRng Is Nothing Then Exit Sub
For Each xCell In xRng
xNum = 0
xCount = 0
xArrChr10 = Split(xCell.Value, Chr(10))
For I = 0 To UBound(xArrChr10)
xArr = Split(xArrChr10(I))
For J = 0 To UBound(xArr)
If xArr(J) <> "" Then
xCount = xCount + 1
If xCount > 3 Then Exit For
End If
xNum = xNum + Len(xArr(J)) + 1
Next
Next
xCell.Characters(1, xNum).Font.Bold = True
Next
End Sub
This comment was minimized by the moderator on the site
HI, how about if i want the first two lines to be bold?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations