离开水的鱼

——飞来飞去!游去游来!俺的收藏夹

导航

excel保存转换文本格式的宏

Posted on 2006-01-12 10:21  Gavin  阅读(1418)  评论(0编辑  收藏  举报
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
RunCheck
End Sub
Private Sub RunCheck()
  Dim i, j
 For i = 1 To Sheet1.UsedRange.Rows.Count
    For j = 1 To Sheet1.UsedRange.Columns.Count
        Sheet1.Cells(i, j) = "'" + Sheet1.Cells(i, j).Text '在文本前面加上一个"'",将其变为字符串,如果想恢复原来的格式,把前面的"'"+几个字符删除,保存一下Excel就行了
    Next
 Next
 
End Sub