I am using Excel 2007 and with a .vbs file and I am trying to delete the first 11 rows of data in a CSV, then delete the very last row after the first 11 are deleted. After this the file should be saved in XLXS format which currently does work.
I have tried the methods below to remove the
first 11 rows but then I do not know how to then select the last used row and then delete that.
I know that if I used
this should delete the first 11 lines I believe but is there a better way? Thanks and I hope this is in the right
place as its my first post. Hello All!
Code:
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = false
objExcel.displayalerts=false
srccsvfile = objFile
Set objWorkbook = objExcel.Workbooks.open(srccsvfile)
Set objWorksheet1 = objWorkbook.Worksheets(1)
'Need formatting code here
tgtxlsfile = "c:\file.xlsx"
objWorksheet1.SaveAs tgtxlsfile, 51
objExcel.Quit()
Set objWorksheet1 = Nothing
Set objWorkbook = Nothing
Set ObjExcel = Nothing
first 11 rows but then I do not know how to then select the last used row and then delete that.
I know that if I used
Code:
For x = 1 to 11
Set objRange = objExcel.Cells(i, 1).EntireRow
objRange.Delete
Next
place as its my first post. Hello All!