2011年12月28日水曜日

Excel vba シート追加、名前変更のエラー防止、「暴力」チェッカー

excelのシートいろいろ禁止文字が有るみたい、暴力的に禁止字を排除する
If trim(shtName) <> "" Then
  If Len(shtName) > 30 Then shtName = Left(shtName, 30)
  shtName = Replace(shtName, "/", "")
  shtName = Replace(shtName, "/", "")
  shtName = Replace(shtName, "[", "")
  shtName = Replace(shtName, "]", "")
  shtName = Replace(shtName, "*", "")
  shtName = Replace(shtName, "*", "")
  shtName = Replace(shtName, "¥", "")
  shtName = Replace(shtName, "\", "")
  shtName = Replace(shtName, ":", "")
  shtName = Replace(shtName, ":", "")
  shtName = Replace(shtName, "?", "")
  shtName = Replace(shtName, "?", "")
  ActiveWorkbook.Worksheets.Add(after:=Worksheets(Worksheets.Count)).Name = shtName
End If

0 件のコメント:

コメントを投稿