LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rename Excel worksheets

Solved!
Go to solution

Hello,

 

In the attached VI, I wanted to generate tab names based on data groups.  I have the Tab names in an array but need some help to get the names to appear on the Tabs.

Thanks.

Download All
0 Kudos
Message 1 of 4
(4,039 Views)
Solution
Accepted by topic author hiNI

There are three functions that will help you add and name Excel Worksheets.  Check out the Help for each of these for more details.  They are:  Excel Get Worksheet, which makes a Worksheet (specified by either Index or Name) the Current Worksheet; Rename Worksheet, which renames the Current Worksheet; and Add Worksheet, which adds an (unnamed) Worksheet to the Worksheet collection.

 

You can start by getting the number of existing Worksheets (with Get Workbook Properties), do enough Add Worksheet to get the number you need, then (in a For Loop) do Get Worksheet followed by Rename Worksheet to name all of your Worksheets.

 

Now you can use Get Worksheet with your selected Names to choose which Worksheet you access.

 

Bob Schor

Message 2 of 4
(3,999 Views)

Hello,

 

How do you go about checking if a worksheet exist, then append to the name a numeric?  Say that MODULATION exist, then on the second iteration, a new tab MODULATION_1 is added and so on?

Thanks.

0 Kudos
Message 3 of 4
(3,953 Views)

You should be able to figure this out, yourself.  You know that Excel Workbook Properties returns the number of Worksheets, you know how to get a specific numbered Worksheet, you know that Excel Workbook Properties will return the name of the current Worksheet, and you know how to program a For loop to loop through things (Worksheets) and accumulate the results in an Array.

 

The Array will be an Array of Worksheet Names.  You can search this Array for "MODULATION" (I prefer "Modulation", less SHOUTING) and then use the functions I described previously to (a) Add a new Worksheet, and (b) change its name to "Modulation_1".

 

Bob Schor 

Message 4 of 4
(3,944 Views)