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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Naming columns in a loop
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

freefeynman123

Poland
6 Posts

Posted - 07/07/2016 :  05:24:47 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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.

Hideo Fujii

USA
1582 Posts

Posted - 07/07/2016 :  09:13:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.


Edited by - Hideo Fujii on 07/07/2016 09:45:26 AM
Go to Top of Page

freefeynman123

Poland
6 Posts

Posted - 07/07/2016 :  09:32:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Works perfectly, thank you very much!
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000