Hi
I am using the following code to write rows in an excel workbook,the problem is that after adding a row using this code, lastrow remain the same so each time I want to add a row,the code add it to the same location
What's wrong?

VB Code:
  1. Set wkbSource = Workbooks.Open("C:\test\test.xls")
  2.  
  3. Set oXLSheet = wkbSource.Worksheets("Stat")
  4.  
  5. sKey = InputBox("Enter the name of the Key that u want to add", "KeyManagement")
  6.  
  7. lastRow = oXLSheet.UsedRange.End(xlDown).Row
  8.     j = lastRow + 1
  9.    
  10. oXLSheet.Cells(j, 1).Value = sKey
  11. oXLSheet.Cells(j, 2).Formula = "=SUMPRODUCT(COUNTIF(INDIRECT(" & Chr(34) & "'Sheet1'!L2 : L1000" & Chr(34) & ")," & Chr(34) & "*" & sKey & "*" & Chr(34) & "))"
  12. oXLSheet.Cells(j, 3).Formula= "=SUMPRODUCT(COUNTIF(INDIRECT(" & Chr(34) & "'Sheet2'!L2 : L1000" & Chr(34) & ")," & Chr(34) & "*" & sKey & "*" & Chr(34) & "))"
  13. oXLSheet.Cells(j, 4).Formula= "=SUMPRODUCT(COUNTIF(INDIRECT(" & Chr(34) & "'Sheet3'!L2 : L1000" & Chr(34) & ")," & Chr(34) & "*" & sKey & "*" & Chr(34) & "))"

thanks in advance