• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

convert csv file into .xlsm file and delete the empty row between the data

Convert csv file into .xlsm(csv file name=1) and delete that csv file,in xlsm file delete the empty row between the data
see both the attachments
 

Attachments

  • 1.csv
    108 bytes · Views: 9
  • 1.xlsm
    14.7 KB · Views: 3
Try this code
Code:
Sub Test()
    Dim wb          As Workbook
    Dim sPath      As String

    Application.ScreenUpdating = 0
        sPath = ThisWorkbook.Path & "\"
        Set wb = Application.Workbooks.Open(sPath & "1.csv")
        Application.DisplayAlerts = False
            wb.SaveAs Filename:=Environ("userprofile") & "\Desktop\1.xlsm", FileFormat:=xlOpenXMLWorkbookMacroEnabled
        Application.DisplayAlerts = True
   
        With Workbooks("1.xlsm")
            On Error Resume Next
                .Worksheets(1).Columns(1).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
            On Error GoTo 0
            .Close True
        End With
    Application.ScreenUpdating = 1
End Sub
 
my csv file is located in C:\Users\user\Desktop
file location where i will place the vba code is C:\Users\user\Desktop\Stock Market\Sholtan
 
Change the path in the code to suit your needs ...
Code:
sPath = ThisWorkbook.Path & "\"
Change to
Code:
Environ("userprofile") & "\Desktop\

And change the following part
Code:
Environ("userprofile") & "\Desktop\1.xlsm"
To
Code:
Environ("userprofile") & "\Desktop\Stock Market\Sholtan\1.xlsm"
 
Back
Top