Application.ScreenUpdating= True '禁用屏幕自动刷新,提高运行效率 Dim rng As Range Dim cell As Range Dim charToFind As String Dim replacement As String Dim startPion As Long Dim filename As String filename = "c:\file.txt" Open filename For Output As #1 Set rng = Selection For Each cell In rng charToFind = "Urel=" ' 检查单元格是否包含指定字符 startPion = InStr(cell.Value, charToFind) If startPion > 0 Then ' cell.Characters(startPion,1).Font.Italic = True cell.Characters(startPion + 1,3).Font.Subscript = True Print #1, cell.Value &":" & Chr(13) & cell.Row & "," & cell.Column & " Urel=" End If charToFind = "Ur=" ' 检查单元格是否包含指定字符 startPion = InStr(cell.Value,charToFind) If startPion > 0 Then ' cell.Characters(startPion,1).Font.Italic = True cell.Characters(startPion + 1,1).Font.Subscript = True Print #1, cell.Value &":" & Chr(13) & cell.Row & "," & cell.Column & " Ur=" End If charToFind = "U=" ' 检查单元格是否包含指定字符 startPion = InStr(cell.Value,charToFind) If startPion > 0 Then ' cell.Characters(startPion,1).Font.Italic = True Print #1, cell.Value &":" & Chr(13) & cell.Row & "," & cell.Column & " U=" End If charToFind = "k=" ' 检查单元格是否包含指定字符 startPion = InStr(cell.Value,charToFind) If startPion > 0 Then ' cell.Characters(startPion,1).Font.Italic = True Print #1, cell.Value &":" & Chr(13) & cell.Row & "," & cell.Column & " k=" End If charToFind = "m3/h" ' 检查单元格是否包含指定字符 startPion = InStr(cell.Value,charToFind) If startPion > 0 Then ' cell.Characters(startPion + 1,1).Font.Superscript = True Print #1, cell.Value &":" & Chr(13) & cell.Row & "," & cell.Column & " m3/h" End If charToFind = "×10" ' 检查单元格是否包含指定字符 startPion = InStr(cell.Value,charToFind) If startPion > 0 Then ' cell.Characters(startPion + 4,2).Font.Superscript = True Print #1, cell.Value &":" & Chr(13) & cell.Row & "," & cell.Column & " ×10" End If Next cell Application.ScreenUpdating = False Close #1
|