I just want to ask if it is possible for a specific text to have an underline? As you can see in the codes below, I want the fname
, stud
and grd
to be underlined when it shows in the Sheet2
sheet. The codes are located at Worksheet_Activate
of Sheet2
.
Set ws = ActiveWorkbook.Worksheets("Sheet1")
Lastrow = ws.Cells(Rows.Count, "C").End(xlUp).Row
For r = 9 To Lastrow
If ws.Cells(r, 3) = CStr(ThisWorkbook.Sheets("Sheet3").Range("K11").value) And ws.Cells(r, 12).value = 1 Then
fname = ws.Cells(r, 4).value
stud = ws.Cells(r, 3).value
grd = ws.Cells(r, 5).value + 1
Text1 = "My name is "
Text2 = " , my student ID is "
Text3 = " and I'm grade "
End If
Next r
With ThisWorkbook.Sheets("Sheet2")
.Range("C72").value = Text1 & fname & Text2 & LRN & Text3 & grd & Text4
End With
I tried using the .Characters(17, 13).Font.Underline = True
, but I don't think I can use the 17,13
or any number since the value of fname
, stud
, and grd
has a different length size.
question from:
https://stackoverflow.com/questions/66056638/vba-excel-underline-specific-text 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…