메인 컨텐츠로 가기

Excel에서 대문자 앞에 공백을 삽입하는 방법은 무엇입니까?

다음과 같이 단어 사이의 모든 공백이 실수로 제거 된 텍스트 문자열 목록이 있다고 가정합니다. 데이터 사이에 공백 행 삽입, 이제 단어를 다음과 같이 구분하기 위해 대문자로 각 문자 앞에 공백을 추가하려고합니다. 데이터 사이에 빈 행 삽입. Excel에서 공백을 하나씩 입력하는 대신 대문자 앞에 공백을 빠르게 추가하는 방법은 무엇입니까?


사용자 정의 함수를 사용하여 대문자 앞에 공백 삽입

불행히도 Excel에서 대문자 앞에 공백을 추가하는 직접적인 방법은 없지만 사용자 정의 함수를 만들어이 작업을 해결할 수 있습니다.

1. 공백을 추가하려는 텍스트 문자열이 포함 된 워크 시트를 활성화하십시오.

2. 누르고 ALT + F11 키를 눌러 Microsoft Visual Basic for Applications 창.

3. 딸깍 하는 소리 끼워 넣다 > 모듈을 클릭하고 다음 코드를 모듈 창.

VBA 코드 : 대문자 앞에 공백 삽입

Function AddSpaces(pValue As String) As String
'Update 20140723
Dim xOut As String
xOut = VBA.Left(pValue, 1)
For i = 2 To VBA.Len(pValue)
   xAsc = VBA.Asc(VBA.Mid(pValue, i, 1))
   If xAsc >= 65 And xAsc <= 90 Then
      xOut = xOut & " " & VBA.Mid(pValue, i, 1)
   Else
      xOut = xOut & VBA.Mid(pValue, i, 1)
   End If
Next
AddSpaces = xOut
End Function

4. 그런 다음이 코드를 저장하고 닫은 다음 워크 시트로 돌아가이 수식을 입력합니다. = addspaces (A1) 데이터 외에 빈 셀에 넣으려면 스크린 샷을 참조하십시오.
문서-추가-공간-앞-대문자-1

5. 그런 다음이 수식을 포함 할 범위 위로 채우기 핸들을 드래그하면 모든 대문자 앞에 공백이 삽입됩니다.
문서-추가-공간-앞-대문자-1

셀의 선행 / 후행 / 추가 공백을 쉽게 제거

Excel 용 Kutools 공백 제거 유틸리티를 사용하면 Excel 사용자가 선택한 셀에서 모든 선행 공백, 후행 공백, 추가 공백 또는 모든 공백을 쉽게 제거 할 수 있습니다.


광고 제거 공간 1

VBA 코드로 대문자 앞에 공백 삽입

다음은 다른 VBA 코드가 도움이 될 수 있습니다. 다음과 같이하십시오.

1. 누르고 ALT + F11 키를 눌러 Microsoft Visual Basic for Applications 창.

2. 딸깍 하는 소리 끼워 넣다 > 모듈을 클릭하고 다음 코드를 모듈 창.

VBA 코드 : 대문자 앞에 공백 삽입

Sub AddSpacesRange()
'Update 20140723
Dim Rng As Range
Dim WorkRng As Range
Dim xOut As String
Dim xValue As String
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Application.ScreenUpdating = False
For Each Rng In WorkRng
    xValue = Rng.Value
    xOut = VBA.Left(xValue, 1)
    For i = 2 To VBA.Len(xValue)
       xAsc = VBA.Asc(VBA.Mid(xValue, i, 1))
       If xAsc >= 65 And xAsc <= 90 Then
          xOut = xOut & " " & VBA.Mid(xValue, i, 1)
       Else
          xOut = xOut & VBA.Mid(xValue, i, 1)
       End If
    Next
    Rng.Value = xOut
Next
Application.ScreenUpdating = True
End Sub

3. 그런 다음 F5 이 코드를 실행하려면 사용하려는 데이터 범위를 선택할 수있는 프롬프트 상자가 나타납니다.
문서-추가-공간-앞-대문자-1

4. 그런 다음 OK 이 프롬프트 상자를 닫으려면 한 번에 대문자 앞에 공백이 삽입되었습니다. 스크린 샷을 참조하십시오.
문서-추가-공간-앞-대문자-1


Kutools for Excel로 모든 대문자 앞에 공백 삽입

Excel 용 Kutools 텍스트 추가 유틸리티를 사용하면 VBA 매크로를 무시하고 Excel에서 쉽게 대문자 앞에 공백을 삽입 할 수 있습니다.

Excel 용 Kutools - 300개 이상의 Excel용 필수 도구가 포함되어 있습니다. 신용카드 없이 모든 기능을 갖춘 30일 무료 평가판을 즐겨보세요! 지금 다운로드!

1. 대문자 앞에 공백을 삽입 할 범위를 선택하고 쿠툴 > 본문 > 텍스트 추가. 스크린 샷보기 :

2. 텍스트 추가 열기 대화 상자에서 공백을 입력하십시오. 본문 상자에서 옵션에만 추가 선택 첫 번째 문자는 대문자입니다. 인사말 추가 만 드롭 다운 목록.

3. 클릭 Ok 다음 스크린 샷과 같이 모든 대문자 앞에 공백을 삽입하려면 버튼을 누릅니다.
doc 대문자 7 앞에 공백 추가

Excel 용 Kutools - 300개 이상의 필수 도구로 Excel을 강화하세요. 신용카드 없이 모든 기능을 갖춘 30일 무료 평가판을 즐겨보세요! 이제 그것을 잡아

노트:이 방법은 첫 글자가 대문자 인 경우 셀 시작 부분에도 공백을 추가합니다. 신청할 수 있습니다 쿠툴 > 본문 > 공백 제거 선택한 셀에서 모든 선행 공백을 제거합니다.


관련 기사 :

최고의 사무 생산성 도구

🤖 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 (9)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
This function handles two problems that the given solution doesn't cover:
1. non-English text (with diacritical marks)
2. successive capitals that should not have spaces after them

` Private Function AddSpaces(sText As String)As String
' Inserts a space immediately before a capital letter, except when successive characters are each capitalized.
' Last Updated: 2022-07-04
'
Dim sRet As String, i As Integer, sChar As String, bPrevWasUCase As Boolean

sRet = Left(sText, 1)
For i = 2 To Len(sText)
sChar = Mid(sText, i, 1)
If sChar = UCase(sChar) And Not bPrevWasUCase Then
sRet = sRet & " " & sChar
bPrevWasUCase = True
Else
sRet = sRet & sChar
bPrevWasUCase = False
End If
Next i

AddSpaces= sRet
End Function`
This comment was minimized by the moderator on the site
Hello friend,

Thanks for your share. I tried your VBA code, but it doesn't work. Our VBA code can handle the non-english text. I have test the french text and spaces are successfully inserted before the capital letters.

Sincerely,
Mandy
This comment was minimized by the moderator on the site
Hello

First thanks a lot for your code example and the explanations. It works very well for my case.

I just have 1 Problem, some of the Strings contain words like URL, which should not be seperated.
Do you see a way to except for example "URL" from adding spaces?

Would be very nice if you can help. I tried already a while, but i dont know how to solve this..


Best regards
luca
This comment was minimized by the moderator on the site
hi wanna ask you if you found solution for you case, if you found solution please provide me with that
This comment was minimized by the moderator on the site
Hi,
Thanks for your comment and advice. I have sent your suggestion to the Kutools project team, I’m sure they’ll improve it soon.
This comment was minimized by the moderator on the site
Found a solution?
This comment was minimized by the moderator on the site
Hi there, your code works fantastic. Do you know how to adapt code 20140723 to work on multiple sheets? I would like to add spaces between capital letters throughout the entire workbook. Thanks!
This comment was minimized by the moderator on the site
i need a help in excel i want to find Uppercase in a cell. for example: Sagar Paul MBA 16:04 i want MBA to be highlighted
This comment was minimized by the moderator on the site
I hope you can see it and give it a trial. Sub Test() Dim Rg As Range, xCell As Range Dim i As Long Dim xChar As String Set Rg = Application.Selection For Each xCell In Rg For i = 1 To xCell.Characters.Count xChar = xCell.Characters(i, 1).Text If Asc(xChar) > 64 And Asc(xChar) < 91 Then xCell.Characters(i, 1).Font.Color = vbRed End If Next Next End Sub
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations