首页->【软件工具包使用(SW/Software Tools Usage)】

7 1

Option Explicit

Sub SheetNameReview()
    Dim k As Integer
    Dim sh As Variant
    
    Dim t As String
    Dim shName(20) As String
    
    k = 0
    
    For Each sh In Sheets
        t = sh.Name
        shName(k) = t
        k = k + 1
        'case 1 can not include the " "
        If InStr(t, " ") Then
        
            Debug.Print "sheet name error "
            t = Replace(t, " ", "_")
            sh.Name = t
        Else

        End If
        
    Next sh
    
End Sub

作者于2019-04-13 12:13:49修改!
楼主可见

  1. shwnyoo 1#

    获取sheetname 并检查是否含有非法字符