Here is the script I am using to add an entry into an excel sheet automactically. I need it to find the last cell with data and add the entry after it. It works, but it searches top to bottom. I need it to go Bottom to Top.
How can I change the direction of my search for the last empty cell from down to up?
'Update Excel Spredsheat
Function UpdateExcel(ExcelFile)
Const xlCellTypeLastCell = 11
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Open(ExcelFile)
Set objWorksheet = objWorkbook.Worksheets(1)
objWorksheet.Activate
Set objRange = objWorksheet.UsedRange
intNewRow = objExcel.ActiveCell.Row + 1
'Update Cells
strNewCell = "B" & intNewRow
objExcel.Range(strNewCell).Activate
objExcel.Range(strNewCell).Value = Date()
strNewCell = "E" & intNewRow
objExcel.Range(strNewCell).Activate
objExcel.Range(strNewCell).Value = "QA"
strNewCell = "F" & intNewRow
objExcel.Range(strNewCell).Activate
objExcel.Range(strNewCell).Value = "QA Accepted"
strNewCell = "J" & intNewRow
objExcel.Range(strNewCell).Activate
objExcel.Range(strNewCell).Value = Date()
strNewCell = "K" & intNewRow
objExcel.Range(strNewCell).Activate
objExcel.Range(strNewCell).Value = "Admin"
strNewCell = "L" & intNewRow
objExcel.Range(strNewCell).Activate
objExcel.Range(strNewCell).Value = "Shipping"
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
End Function
Thanks,
How can I change the direction of my search for the last empty cell from down to up?
'Update Excel Spredsheat
Function UpdateExcel(ExcelFile)
Const xlCellTypeLastCell = 11
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Open(ExcelFile)
Set objWorksheet = objWorkbook.Worksheets(1)
objWorksheet.Activate
Set objRange = objWorksheet.UsedRange
intNewRow = objExcel.ActiveCell.Row + 1
'Update Cells
strNewCell = "B" & intNewRow
objExcel.Range(strNewCell).Activate
objExcel.Range(strNewCell).Value = Date()
strNewCell = "E" & intNewRow
objExcel.Range(strNewCell).Activate
objExcel.Range(strNewCell).Value = "QA"
strNewCell = "F" & intNewRow
objExcel.Range(strNewCell).Activate
objExcel.Range(strNewCell).Value = "QA Accepted"
strNewCell = "J" & intNewRow
objExcel.Range(strNewCell).Activate
objExcel.Range(strNewCell).Value = Date()
strNewCell = "K" & intNewRow
objExcel.Range(strNewCell).Activate
objExcel.Range(strNewCell).Value = "Admin"
strNewCell = "L" & intNewRow
objExcel.Range(strNewCell).Activate
objExcel.Range(strNewCell).Value = "Shipping"
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
End Function
Thanks,