To write test Results into a column in excel
- 8 years ago
Azeddin_Margani wrote:
inputRow = excelMainSheet.UsedRange.Rows.Count;
excelMainSheet.Range("K" + inputRow).Value =CardNum;
OK. You're not mixing COM and DDT. That's good. :)
As previously explained, the above code is your problem. UsedRange gets the last row. So you are always writing to the last row.
If this is looping through 100 rows of data, I assume you must have it in some sort of loop?
In which case (pseudocode) you want something like:
Loop Start Do your test and extract the value Excel.Cells(Loop, Column) = Your_Value End Loop
Or something like that.
Basically, as shankar_r says, you need to track the row you are on. Which I presume you are (or will be) doing if you're using the same sheet for you input data?
(Incidentally, I've used the "Cells" method in Excel. Which uses a numeric for both Row and Column. You can use Range, but it's really designed for updating multiple cells in one go. But it will work with a single cell value.)