The Following OC function is designed to collect the columns of all worksheets with names beginning with the characters in the string "strWksStem" into a single newly created worksheet (Returns the name of the new worksheet)
It works in Origin 7.5-SR6 ... Needs a little tweaking though to meet your exact requirements...
string CollectWksCols(string strWksStem)
{
vector<string> vctWksNames;
vctWksNames.RemoveAll();
string strNameStem=strWksStem;
strNameStem+="*";
foreach(PageBase pB in Project.Pages)
{
if(pB.GetType()==EXIST_WKS)
{
string strWksName;
if(pB.GetName(strWksName)==true)
{
if(strWksName.Match(strNameStem)==true)
{
vctWksNames.Add(strWksName);
}
}
}
}
int NumMatches=vctWksNames.GetSize();
Worksheet WksDest;
if(WksDest.Create("origin.otw")==false) goto ErrorExit;
int nCols=WksDest.GetNumCols()-1;
for(int i=nCols;i>=0;i--)
{
WksDest.DeleteCol(i);
}
for(i=0;i<NumMatches;i++)
{
Worksheet Wks;
if(Wks.Attach(vctWksNames[i])==false) goto ErrorExit;
foreach (Column col in Wks.Columns)
{
Dataset dSource(col);
if(dSource.IsValid()==true)
{
int i=WksDest.AddCol();
if(i==(-1)) goto ErrorExit;
Dataset dDest;
if(dDest.Attach(WksDest,i)==false) goto ErrorExit;
dDest.SetSize(dSource.GetSize());
dDest=dSource;
}
}
}
if(WksDest.GetNumCols()>0)
{
return (WksDest.GetPage().GetName());
}
ErrorExit:
if(WksDest.IsValid()==true)
{
WksDest.Destroy();
}
return ("");
}