shabbaranks
Registered User.
- Local time
- Today, 03:27
- Joined
- Oct 17, 2011
- Messages
- 300
Hi,
Im looking to export my listbox values to a single workbook BUT a new sheet is created per export. There are 6 listboxes in total and I already have the code to export a single listbox but if I try to use this code its going to overwrite the csv each time - I was wondering if anyone could help please?
Im looking to export my listbox values to a single workbook BUT a new sheet is created per export. There are 6 listboxes in total and I already have the code to export a single listbox but if I try to use this code its going to overwrite the csv each time - I was wondering if anyone could help please?
Code:
Dim i As Integer
Dim n As Integer
Dim strLine As String
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("D:\DatabaseHome\ExportCombinedHrs.csv", True)
For i = 0 To Me.CombinedHrsAdminNC_lb.ListCount - 1
For n = 0 To Me.CombinedHrsAdminNC_lb.ColumnCount - 1
strLine = strLine & """" & Me.CombinedHrsAdminNC_lb.Column(n, i) & ""","
Next n
strLine = Left(strLine, Len(strLine) - 1)
a.writeline (strLine)
strLine = ""
Next i
MsgBox "Your export file is located in D:\DatabaseHome"