2017-12-08 2 views
1

나는 Excel에서 도움이 필요합니다. 그래서 난 그냥 내가 Guest_nameGuest_age 굵게로 얻을 수있는 방법 궁금Excel Vba 문자열의 일부 텍스트를 굵게 표시

Range("A1").Value = "This Year we are having our guest " &Guest_name &" who is currently " &Guest_age &"years old, spending holidays with us" 

:

나는 코드와 매크로에 의해 가치를 셀 수 있습니다.

감사

답변

2

다음은 답변의 한 가지 버전입니다. vba에게 시작하고 끝낼 곳을 지시하기 위해 Characters을 사용하십시오.

Sub test() 

Dim guest_name, guest_name_len As Integer 
Dim guest_age, guest_age_len As Integer 

guest_name = "tester" 
guest_name_len = Len(guest_name) 
guest_age = "999" 
guest_age_len = Len(guest_age) 
Debug.Print guest_name_len & "/" & guest_age_len 

Range("A1").Value = "This Year we are having our guest " & guest_name & " who is currently " & guest_age & "years old, spending holidays with us" 

With Range("A1").Characters(Start:=35, Length:=guest_name_len).Font '35 characters counted (this year....) 
.FontStyle = "bold" 
End With 
With Range("A1").Characters(Start:=35 + guest_name_len + 18, Length:=guest_age_len).Font '18 characters counted (who is... years old) 
.FontStyle = "bold" 
End With 

End Sub 
0

사용 InStr이이 범위의 .value2 건물 내의 각을 찾은 문자열의 .Characters 속성에 사실을 .font.bold = 적용.

관련 문제