Hi,
I am new to this forum and scripting. I am tring to add a row to an excel file. The file contains 6 colums and the rows are populated with peoples First Name, Mid Init, Last name, birthdate, job type and date.
I am trying to add a row with Description of the colums (header)at the begining of the spreadsheet. I am not sure how to go about doing this?
Below is my code.
When I compile this script, it doesn't do anything to my file.
Sub mymacro1()
'
' mymacro1 Macro
' Macro
'
'
Set objXL = CreateObject("Excel.Application")
Set objWB = objXL.WorkBooks.Open("C:\data\telet.csv")
Set objWS = objXL.ActiveWorkBook.WorkSheets("tele")
With objWS
objWS.Rows("1:1").Insert
objWS.Application.Selection.End(xlDown).Select()
objWS.Range("A1").Value = "First Name"
objWS.Range("B1").Value = "Middel int"
objWS.Range("C1").value = "Last name"
objWS.Range("D1").value = "Start Date"
objWS.Range("E1").value = "Expiration Date"
objWs.Range("F1").value = "Dept Num"
end with
objWB.Close
objXL.Quit
End Sub
I am new to this forum and scripting. I am tring to add a row to an excel file. The file contains 6 colums and the rows are populated with peoples First Name, Mid Init, Last name, birthdate, job type and date.
I am trying to add a row with Description of the colums (header)at the begining of the spreadsheet. I am not sure how to go about doing this?
Below is my code.
When I compile this script, it doesn't do anything to my file.
Sub mymacro1()
'
' mymacro1 Macro
' Macro
'
'
Set objXL = CreateObject("Excel.Application")
Set objWB = objXL.WorkBooks.Open("C:\data\telet.csv")
Set objWS = objXL.ActiveWorkBook.WorkSheets("tele")
With objWS
objWS.Rows("1:1").Insert
objWS.Application.Selection.End(xlDown).Select()
objWS.Range("A1").Value = "First Name"
objWS.Range("B1").Value = "Middel int"
objWS.Range("C1").value = "Last name"
objWS.Range("D1").value = "Start Date"
objWS.Range("E1").value = "Expiration Date"
objWs.Range("F1").value = "Dept Num"
end with
objWB.Close
objXL.Quit
End Sub