在《你可以拥有你想要的生活》一书中有这样一段话:“这个世界的诱惑远比你想的多,通往成功的道路也比你想的要更多。无论你选择什么,我都希望那件事情是你真心热爱的。我希望你能坚持自我,善用天赋;不要浪费自己的才华,不要忘记自己所热爱的事情,也不要忘记你心中的激情。不要去奋斗,而是要去热爱。”因为热爱,我们才可以长久持续地努力;因为热爱,我们才能奔向更好的前程。
Sub ExportRange()
Dim Filename As String
Dim NumRows As Long, NumCols As Integer
Dim r As Long, c As Integer
Dim Data
Dim ExpRng As Range
Set ExpRng = Application.Intersect(Selection, ActiveSheet.UsedRange)
NumCols = ExpRng.Columns.Count
NumRows = ExpRng.Rows.Count
Filename = Application.DefaultFilePath & "\textfile.csv"
Open Filename For Output As #1
For r = 1 To NumRows
For c = 1 To NumCols
Data = ExpRng.Cells(r, c).Value
If IsNumeric(Data) Then Data = Val(Data)
If IsEmpty(ExpRng.Cells(r, c)) Then Data = ""
If c <> NumCols Then
Write #1, Data;
Else
Write #1, Data
End If
Next c
Next r
Close #1
MsgBox ExpRng.Count & " cells were exported to " & Filename, vbInformation
End Sub