Hi
I am a newbie and would lik to copy paste data from one shet to another. data from one sheet lies on 9th column. I am stuck on the error. "Object required for Rows".
Also any feasible suggestions: Can we copy the entire contents of the column into another sheet.
The code goes this way:
function CreateExcel()
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Visible = True
set CreateExcel = ExcelApp
End function
Dim ExcelApp, excelSheet, OldSheet, NewSheet, LastRow
Set ExcelApp = CreateExcel()
Set excelSheet = ExcelApp.Workbooks.Open("C:\Documents and Settings\Sachin\Desktop\Parse_File.xls")
Set OldSheet = excelSheet.Sheets.Item("Book2")
'Set Rows = OldSheet.Range
Set workbook = ExcelApp.ActiveWorkbook
LastRow = workbook.Range(.cells(rows.count,"A").End(xlup))
'(.Cells(Rows.Count, "A").End(xlUp).Row)
msgbox LastRow
'add a sheeet
workbook.Sheets.Add
Set NewSheet = excelSheet.Sheets.Item("Sheet1")
for i = 1 to LastRows
tempValue = OldSheet.Cells(i,9)
msgbox tempValue
'copy cell
if tempValue <> "" then
NewSheet.Cells(i,1).Value = OldSheet.Cells(i,9).Value
end if
next
Thanks
Bookmarks