The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum
 Origin Forum
 Naming columns in a loop

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
freefeynman123 Posted - 07/07/2016 : 05:24:47 AM
I would like to name a columns in a loop to have something like that:



where Y columns are named as b1, b2, b3 etc.

I tried with a script like that:

ncol = wks.GetNumCols();
for (i = 2; i<= ncol; i +=1);
{
wks.Columns(i).SetName("b$(i)")
}

although it doesn't print any mistakes I can't see any sign of it working. I would appreciate any help.

2   L A T E S T    R E P L I E S    (Newest First)
freefeynman123 Posted - 07/07/2016 : 09:32:51 AM
Works perfectly, thank you very much!
Hideo Fujii Posted - 07/07/2016 : 09:13:32 AM
Hi freefeynman123,

> it doesn't print any mistakes

The semicolon(;) at the end of the "for" command line causes no loop.
Anyway, the following code should work:
ncol = wks.ncols;
for (ii = 2; ii<= ncol; ii +=1) {
  wks.col$(ii).name$="b$(ii-1)";
}
Please try.

--Hideo Fujii
OriginLab

P.S. By the way, you can change the column names in enumerated way from the user interface
by double-clicking the first column to show Column Properties dialog, enter the prefix ("b" in
your case) at the Short(or Long) Name, select "Enumerate Labels", choose "Enumerate" at the
Short(or Long) Name dropdown.


The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000