You need to use Share name for that drive that should begin with \\
Rich (BB 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 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
OOOps,
Sorry
shoule beRich (BB code):Print #1, Mid$(temp, 3)
Rich (BB code):Print #1, Mid$(txt, 3)
OOOps,
Sorry
shoule beRich (BB code):Print #1, Mid$(temp, 3)
Rich (BB code):Print #1, Mid$(txt, 3)
For ii = 1 To .Columns.Count
temp = temp & "," & .Cells(i, ii).Text
Next
For ii = 1 To .Columns.Count
If Cells(i, ii).Text Like "*,*" Then flg = True
temp = temp & "," & IIf(flg,Chr(34), "") & _
.Cells(i, ii).Text & IIf(flg,Chr(34), "")
flg = False
Next
For ii = 1 To .Columns.Count
If Cells(i, ii).Text Like "*,*" Then flg = True
temp = temp & "," & IIf(flg, Chr(34), "") & _
.Cells(i, ii).Text & IIf(flg, Chr(34), "")
flg = False
Next
txt = txt & vbCrLf & Mid$(temp, 2): temp = ""
[B]Next[/B]
change
toRich (BB code):For ii = 1 To .Columns.Count temp = temp & "," & .Cells(i, ii).Text Next
This will wrap those string includes comma(s) with double quotes, so it will fit to the right column when out put.Rich (BB code):For ii = 1 To .Columns.Count If Cells(i, ii).Text Like "*,*" Then flg = True temp = temp & "," & IIf(flg,Chr(34), "") & _ .Cells(i, ii).Text & IIf(flg,Chr(34), "") flg = False Next
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
If Cells(i, ii).Text Like "*,*" Then flg = True
temp = temp & "," & IIf(flg,Chr(34), "") & _
.Cells(i, ii).Text & IIf(flg,Chr(34), "")
flg = False
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$(txt, 3)
Close #1
End Sub
Yeah, I think I made it unclear
Rich (BB 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 If Cells(i, ii).Text Like "*,*" Then flg = True temp = temp & "," & IIf(flg,Chr(34), "") & _ .Cells(i, ii).Text & IIf(flg,Chr(34), "") flg = False 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$(txt, 3) Close #1 End Sub
Yeah, I think I made it unclear
Rich (BB 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 If Cells(i, ii).Text Like "*,*" Then flg = True temp = temp & "," & IIf(flg,Chr(34), "") & _ .Cells(i, ii).Text & IIf(flg,Chr(34), "") flg = False 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$(txt, 3) Close #1 End Sub