Excel 用于批量把单元格设置为"文本格式保存的数字"的宏

首先把所有的数字录入(或者导出为)井号+数字的格式,比如“#3333333323424234234234”,然后运行下面的宏:

Sub Num2Text()
    If Not TypeOf Application.Selection Is Range Then
        MsgBox "You must select cells!"
        Return
    End If
    
    For Each cell In Application.Selection.Cells
        If cell.Text <> "" Then
              cell.FormulaR1C1 = "'" + Replace(cell.Text, "#", "")
        End If
    Next
End Sub

 

posted @ 2015-03-14 17:10  Haart  阅读(653)  评论(0编辑  收藏  举报