I'm trying to add separator in each cell.
But this code bellow adding seperator on all cells empty or not, I need seperator only on Not empty cells.
Could you help me, tks a lot
Dim Range As Object, Line As Object, Cell As Object
Dim StrTemp, chemin As String
Dim Separateur As String
Separateur = ","
'WBDest.Activate
Set Range = Worksheets(1).Columns(i)
'Set Range = Worksheets(1).Columns(i).SpecialCells(xlCellTypeBlanks) ' Not work
Open "C:\export\" + Str(i) + ".csv" For Output As #1
For Each Line In Range.Rows
StrTemp = ""
For Each Cell In Line.Cells
StrTemp = StrTemp & CStr _
(Cell.Text) & Separateur
Next
Print #1, StrTemp '= " "
Next
Close
Can you try to validate cell values for non-blanks?
For Each Line In Range.Rows
StrTemp = ""
For Each Cell in Line.Cells
If Cell.Text <> "" then 'validate for non-blanks
StrTemp = StrTemp & CStr _
(Cell.Text) & Separateur
End if
Next
Print #1, StrTemp '= " "
Next
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.