Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try this code. modify path and file name as necessary
Sub WriteCSV() Const Delimiter = "," Const ForReading = 1, ForWriting = 2, ForAppending = 3 Const MyPath = "C:\temp\" Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0 Set fswrite = CreateObject("Scripting.FileSystemObject") WriteFileName = "text.csv" 'open files WritePathName = MyPath + WriteFileName fswrite.CreateTextFile WritePathName Set fwrite = fswrite.GetFile(WritePathName) Set tswrite = fwrite.OpenAsTextStream(ForWriting, TristateUseDefault) LastRow = Cells(Rows.Count, "A").End(xlUp).Row For RowCount = 1 To LastRow LastCol = Cells(RowCount, Columns.Count).End(xlToLeft).Column For ColCount = 1 To LastCol If ColCount = 1 Then OutputLine = Cells(RowCount, ColCount) Else OutputLine = OutputLine & Delimiter & Cells(RowCount, ColCount) End If Next ColCount tswrite.writeline OutputLine Next RowCount tswrite.Close Exit Sub End Sub "Ram" wrote: I have VBA macro that converts excel to csv. It also removes hidden characters. But if a cell start with "=" then it gives an error (I used clean in the VBA). I know that = is for entering formulas. But I enter in the cell as '= sfdsdfdsf. This way I can put = as the first letter in the cell. Does anyone know how to do get rid of this error |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|