使用vba为excel文字添加下划线

Sub city()
Dim a As String
Dim b1 As String
Dim b2 As String
Dim b3 As String
    For i = 2 To 45
        For j = 2 To 13
            a = Worksheets("city").Cells(i, j)
            b1 = Mid(a, 1, 1)
            If (b1 = "b" Or b1 = "A" Or b1 = "B" Or b1 = "C") Then
               b2 = Mid(a, 2, 1)
               If (b2 = "b" Or b2 = "A" Or b2 = "B" Or b2 = "C") Then
                    b3 = Mid(a, 3, 1)
                     If (b3 = "b" Or b3 = "A" Or b3 = "B" Or b3 = "C") Then
                        Worksheets("city").Cells(i, j).Characters(1, 3).Font.Underline = xlUnderlineStyleSingle

                     End If
                End If
         End If
            
        Next j
    Next i

End Sub

使用vba为excel文字添加下划线,示例代码




你可能感兴趣的:(Visual,Basic,excel,vba,下划线)