Ah, is that so ?
Thanks, I never thought that.
Thanks Seiya and Mark for the explanation, it works now, just one question why is it when i have data 31/03/2009 in orignal data but when i open CSV file it changes to 3/31/2009
[/FONT]
I think it depends on your country setting/locale of Windows.
Sub test()
Dim temp As String, txt As String, i As Long, ii As Long
With Sheets("sheet2").UsedRange
For i = 1 To .Rows.Count
For ii = 1 To .Columns.Count
temp = temp & "," & .Cells(i, ii).Text
Next
txt = txt & vbCrLf & Mid$(temp, 2) : temp = ""
Next
End With
Open "U:\TL\PV\CSV\test.csv" For Output As #1
Print #1, Mid$(temp, 3)
Close #1
End Sub
If you want to save csv and exactly how it looks then try
Code:Sub test() Dim temp As String, txt As String, i As Long, ii As Long With Sheets("sheet2").UsedRange For i = 1 To .Rows.Count For ii = 1 To .Columns.Count temp = temp & "," & .Cells(i, ii).Text Next txt = txt & vbCrLf & Mid$(temp, 2) : temp = "" Next End With Open "U:\TL\PV\CSV\test.csv" For Output As #1 Print #1, Mid$(temp, 3) Close #1 End Sub
Sub test()
Dim temp As String, txt As String, i As Long, ii As Long
With Sheets("sheet2").UsedRange
MsgBox .Address
For i = 1 To .Rows.Count
For ii = 1 To .Columns.Count
temp = temp & "," & .Cells(i, ii).Text
Next
txt = txt & vbCrLf & Mid$(temp, 2) : temp = ""
Next
End With
MsgBox txt
Open "U:\TL\PV\CSV\test.csv" For Output As #1
Print #1, Mid$(temp, 3)
Close #1
End Sub
Run the code then return with the message.
Code:Sub test() Dim temp As String, txt As String, i As Long, ii As Long With Sheets("sheet2").UsedRange MsgBox .Address For i = 1 To .Rows.Count For ii = 1 To .Columns.Count temp = temp & "," & .Cells(i, ii).Text Next txt = txt & vbCrLf & Mid$(temp, 2) : temp = "" Next End With MsgBox txt Open "U:\TL\PV\CSV\test.csv" For Output As #1 Print #1, Mid$(temp, 3) Close #1 End Sub
Sub test()
Dim temp As String, txt As String, i As Long, ii As Long
With Sheets("sheet2").UsedRange
For i = 1 To .Rows.Count
For ii = 1 To .Columns.Count
temp = temp & "," & .Cells(i, ii).Text
Next
txt = txt & vbCrLf & Mid$(temp, 2) : temp = ""
Next
End With
CreateObject("WScript.Shell").<WBR>CurrentDirectory = "\\server\TL\PV\CSV"
Open "test.csv" For Output As #1
Print #1, Mid$(temp, 3)
Close #1
End Sub