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
 Extracting data from sheets in workbook

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
leonardo.a027 Posted - 01/18/2017 : 12:54:08 PM
Hi!
I am trying to extract data from a specific column and row of all worksheets in a specific workbook. I want to put the value of the specific cells in a new sheet in a new book, each value has to be identified with the name of the worksheet.
So far I have tried this:

doc -e LB
{
  int j=1;
  if (%H == "Book1")
    {
    loop(ii,1,page.nlayers) 
       {
        string str = wks.name$;
        [book2](sheet1)!2[j] = [%H]$(ii)!2[2];
        [book2](sheet1)!1[j] = str;
        j++;
      }
    }
}

But when I run it, nothing happens in the new book and new sheet that I previously created.
It'e been a long time trying to solve this.
5   L A T E S T    R E P L I E S    (Newest First)
Nornimices Posted - 02/16/2017 : 09:20:25 AM
I am not sure about it.
leonardo.a027 Posted - 01/18/2017 : 2:57:05 PM
Thanks a lot Hideo!
Now it works just fine :)!
Hideo Fujii Posted - 01/18/2017 : 2:50:49 PM
Hi leonardo.a027,

You need to specify which sheet (=layer), So, in the first line of the loop block, you can use:
  string str = layer$(ii).name$;
instead of:
  string str = wks.name$;
Works?

--Hideo Fujii
Originlab
leonardo.a027 Posted - 01/18/2017 : 2:41:47 PM
Hi Hideo.
Thanks a lot for the help.
There's only one problem:
When I run the code, the output is:

Sheet4	1
Sheet4	2
Sheet4	3
Sheet4	4

As you can see the name of the sheets are all the same and they should be: Sheet1, Sheet2, Sheet3 and Sheet4.
I am not sure where's the problem.
Thanks again :).
Hideo Fujii Posted - 01/18/2017 : 2:27:45 PM
Hi leonardo.a027,

The main problem in your code is that the notation, "[Book]Sheet!Column" is not an operational entity
such as for assignment, but for defining the range, mainly used in the Range declaration or sometime
as an argument of an x-function. Keeping this in mind, the following code should work:
////////////////////////////////////////////
doc -e LB
{
  int j=1;
  if (%H == "Book1")
    {
    loop(ii,1,page.nlayers) 
       {
        string str = wks.name$;
        range iw21=[book2]sheet1!1;
        range iw22=[book2]sheet1!2;
        range iw12= [%H]$(ii)!2;
        iw22[j] = iw12[2];
        iw21[j]$ = str$;
        j++;
      }
    }
}
////////////////////////////////////////////

Hope this helps.

--Hideo Fujii
OriginLab

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