Posted to microsoft.public.excel.programming
|
|
Dumping the contents of a VBA array to a sheet
Where does the 1000 times enter into this?
Alan Beban
Kirk Lingner wrote:
Sorry for the vagueness.
Here's a snippet of code (it's taking the range and writing it out to a
file via the cut and paste method).
' *******
' Creates a shell of a file into which the values will be stored.
' Uses Cut-and-Paste logic.
' *******
.. v_master is the name of ThisWorkbook
.. v_fn is the .csv file that will be created
.. v_data is the range that will be written out
Sub CreateFile(ByVal v_master As String, ByVal v_fn As String, ByVal
v_data As Range)
' Remove prior version, if any.
' Error(53) will occur if file does not exist.
On Error Resume Next
Kill v_fn & ".csv"
' Create new file
Application.SheetsInNewWorkbook = 1
' By adding a new workbook, the new workbook becomes active.
Workbooks.Add
' Paste values
v_data.Copy
ActiveCell.PasteSpecial Paste:=xlPasteValues, _
Operation:=xlPasteSpecialOperationNone, _
SkipBlanks:=False, _
Transpose:=False
Application.CutCopyMode = False
' Rename, save and close
With ActiveWorkbook
.SaveAs _
FileName:=v_fn, _
FileFormat:=xlCSV, _
CreateBackup:=False
.Close _
SaveChanges:=False
End With
Workbooks(v_master).Activate
End Sub
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
|