02-24-2010 02:52 PM
Hello everyone,
In my labview code, I am trying to determine the last used row in excel. I thought I could use the Worksheet:UsedRange feature in labview, but there's a pretty annoying bug in excel that if I ever used a row below where it ends, it stores the unused row as used. I end up with an array that is too large, so it populates the non-used rows with zeros and it's screwing up some of my graphs.
Normally in VBA I count the number of rows using the following formula:
LastRow = Cells(Rows.Count, "F").End(xlUp).Row
I would like to replicate this formula in Labview but am having difficulties doing so.
Can someone help?
Thanks,
Matt
02-24-2010 04:40 PM
02-26-2010 12:50 PM
02-26-2010 01:13 PM
02-26-2010 01:40 PM
smercurio_fc wrote:
Why not just go to the F65536 cell and then to an xlUp?
That may not work. Suppose the OP isn't using column F. Or column F is "short" in its row usage. (Other rows might have information down to let's say row 100, but in F, the bottom rows are lacking some data. xLup make take it higher into the body of the spreadsheet then intended.)
02-26-2010 01:54 PM
03-01-2010 01:04 PM
is there no way to replicate my LastRow formula in the OP?
Thanks,
Matt
03-01-2010 03:09 PM - edited 03-01-2010 03:13 PM
I do not know how to do Cells(Rows.Count, "F") using the ActiveX interface in LabVIEW. The closest I could come up with was this:
Perhaps someone else may be able to indicate how to replicate that directly.
03-01-2010 04:46 PM
did you try the Report generation toolkit functions?
Excel Get Last Row VI
03-01-2010 05:08 PM
That VI in the toolkit still relies on the UsedRange property and would still be affected by the fundamental problem with the UsedRange property sometimes including cells that may have been cleared and aren't really "used" any more.
Also, as far as I know, the Report Generation Toolkits don't open existing Excel files, but rather create new workbooks. I could be wrong on this latter one, as I actively used the toolkit a long time ago, and I only did a basic scan over all the VIs from the online documentation.