Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: import excel Command: Automatic Adjustment of cellrange Option in Loop


From   Roberto Liebscher <[email protected]>
To   [email protected]
Subject   st: import excel Command: Automatic Adjustment of cellrange Option in Loop
Date   Fri, 21 Feb 2014 21:36:40 +0100

Hello Statalisters,

I have got several excel files at hand which I would like to convert into *.dta files. I would like to write a loop importing all the excel files and save them as *.dta. However, the problem is that the cellrange is not the same for every file. So I would be happy to know if there is a way to "automate" the adjustment for the cellrange option?

In the end the loop should look like this:

forvalues i=1/100 {
       import excel "C:\`i'.xlsx", cellrange(A3:XX) firstrow clear
        save `i'.dta
}

where XX is supposed to be the last cell in the bottom right of the worksheet that has a value in it. Is there any chance to do this?

Any help is highly appreciated.

Best,
Roberto

--
Roberto Liebscher
Catholic University of Eichstaett-Ingolstadt
Department of Business Administration
Chair of Banking and Finance
Auf der Schanz 49
D-85049 Ingolstadt
Germany
Phone:  (+49)-841-937-1929
FAX:    (+49)-841-937-2883
E-mail:   [email protected]
Internet: http://www.ku.de/wwf/lfb/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index