LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

make specific Excel cell active

I have an elaborate VI created which opens an Excel file, copies its contents and places them in an ActiveX container on the front panel, serving as a template. Then values are entered; some come from two arrays created by a pair of interactive periodic tabels, some are entered manually, some are read in from a high precision balance and others are calculated based on these.  All manually entered values are entered via a virtual keypad, since the entire application will be run from a touch screen monitor, sans mouse or keyboard.  The only issue I have remaining (for now) is related to the keypad.  Specifically, when I hit the enter key to enter the value into the current cell, I need to advance the cursor to the next cell down.

 

I think I've found how to do this with tables, but I can't seem to get it when working in the ActiveX container, where I'm working in an excel environment.

 

If I can figure out how to set the active cell, I can do that initially, to place the cursor in the first cell automatically, and I can advance to the next cell each time a value is entered, much the way it works if you are in Excel and you enter a value and hit the Enter key.  Sounds simple...just missing something small I think.

0 Kudos
Message 1 of 9
(3,505 Views)
In a nutshell, I know how to see which cell is active ("get").  I just need to know how to make a cell active ("set").
0 Kudos
Message 2 of 9
(3,503 Views)

Could You Upload your VI so I can see what you have done so far?

0 Kudos
Message 3 of 9
(3,431 Views)

Hello,

 

I am in the same situation as Dan.  Is there a solution to set the Active Cell in Excel?

 

Thank you,

Tin

0 Kudos
Message 4 of 9
(2,828 Views)

@scorer35 wrote:

I am in the same situation as Dan.  Is there a solution to set the Active Cell in Excel?

 


Of course there is.  Attach your code (meaning a file that has the extension .vi, not a picture) that include the code using Excel.

 

Bob Schor

0 Kudos
Message 5 of 9
(2,818 Views)

Hello Bob,

 

I am attaching the VI.  If you click on start, Excel will open with the highlighted cell as "A1".  After you click "Write Data to Excel"  data will be written, but the highlighted cell in excel is still A1.  I want to be able to highlight any other cell in excel like "C7" so that the next time I click on "Write Data to Excel", the new data will start at C7.

 

Any suggestions or ideas is appreciated.

 

Thank you,

Tin

Download All
0 Kudos
Message 6 of 9
(2,810 Views)

Thanks.  From the code you attached, I see you are running LabVIEW 2012, which is pretty old.  I'm guessing you do not have the Report Generation Toolkit available to you, as you seem to be using ActiveX for all your Excel calls.  

 

I went looking for some older code where I updated specific cells, but I think I did this by having LabVIEW code that knew the cell location and wrote the data in the correct cell.  I thought I remembered a function (maybe I wrote such  thing, but I doubt it) that would do what I think you want, leave a cell selected so the user could manually enter data there.  After developing a number of routines that save data in Excel Workbooks, both reading and writing multiple sheets, we've adopted the policy that when LabVIEW is running Excel, users keep their hands off the Workbook, as they can only "mess it up".

 

Sorry I didn't have a direct answer to your question.  But there are number of other Forum users who really know the ins and outs of ActiveX and Excel, and can probably point you to the right spot, especially now that they see what you are trying to do.

 

Bob Schor

0 Kudos
Message 7 of 9
(2,806 Views)

Hi Tin,

 

I want to be able to highlight any other cell in excel

The simplest way to learn ExcelVBA is to use the macro recorder built into Excel.

Using the macro recorder you learn about the commands/objects/methods to use when you want to automate Excel…

 

Having done so I just learned to use the Select method of the Range object to highlight a cell range.

All you have to do in LabVIEW is to call the very same method (using a method node) on a range object:

check.png

Btw. a FOR loop set to iterate just once is pure RubeGoldberg! (Calling the Select method is RubeGoldberg too, but you wanted to know about that one method…)

 

so that the next time I click on "Write Data to Excel", the new data will start at C7.

From an "automation" point of view this is non-sense: your code should always know where to write data to. No need to rely on active cells set in previous function calls (with possibly the user selecting other cells in the mean time)!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 9
(2,800 Views)

Hello GerdW,

 

Thanks for your response.  I added the range select and was able to get what I needed.  Thank you.

 

Regards,

Tin

0 Kudos
Message 9 of 9
(2,785 Views)