LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

last row in excel

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

0 Kudos
Message 1 of 12
(7,117 Views)

Hi,

 

Take a look at this thread. Michael Munroe has posted a VI that should help.

 

cheers

 

David

Message 2 of 12
(7,101 Views)
Thank you for the link.  The problem is, I still run into the same "used range" issue even with the provided code.
0 Kudos
Message 3 of 12
(7,077 Views)
Why not just go to the F65536 cell and then to an xlUp?
Message 4 of 12
(7,071 Views)

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.)

0 Kudos
Message 5 of 12
(7,059 Views)
I only used column F because that's what the OP had in the original VBA code, so I assumed that was a column that was being used as a "key".
0 Kudos
Message 6 of 12
(7,054 Views)

is there no way to replicate my LastRow formula in the OP?

 

Thanks,

Matt

0 Kudos
Message 7 of 12
(7,017 Views)

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.

Message Edited by smercurio_fc on 03-01-2010 03:13 PM
0 Kudos
Message 8 of 12
(6,997 Views)

did you try the Report generation toolkit functions?

 

Excel Get Last Row VI

Anil Punnam
CLD
LV 2012, TestStand 4.2..........
0 Kudos
Message 9 of 12
(6,976 Views)

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.

0 Kudos
Message 10 of 12
(6,970 Views)