[Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register]

Author Message
BBrinson
General User

Joined: 20 May 2005
Posts: 6

 Posted: Tue May 31, 2005 10:11 am    Post subject: In need of advice on macro to step thru column of data I am in need of advice or direction for a macro that will start at the top of a column of data, calculate the number of rows, then execute a function on that row, then drop to the next row repeating the function. My data will always start in cell A7 but could end at cell A100 or A75 or A150. I know a loop of sorts will work, but how do I determine the number of rows and what is the context for counters in oo? Thank you
General User

Joined: 17 Jan 2005
Posts: 8
Location: England

 Posted: Tue May 31, 2005 11:57 am    Post subject: Well a loop seems the obvious answer, in conjunction with a counting variable along the lines of :- count = 7 Do code to set cell location [oCell=oSheet.getCellByposition(col, row) where row would = count] code to read cell if cell = no value then exit loop else count = count + 1 end if loop count - 1 equals number of rows What I am not clear about is do you have to execute a function on each cell with one of the arguements to the function being the number of cells in the column or is the arguement to the function the place of the cell in the column e.g. cell A7 arguement is 1 (first cell) cell A17 arguement is 10 (10th cell in column). If the function arguement is the total number of cells then use a loop to discover the number of cells then a second loop to step through the cells applying the formula, or am I missing something here? Cheers Roy
BBrinson
General User

Joined: 20 May 2005
Posts: 6

 Posted: Tue May 31, 2005 12:54 pm    Post subject: Thanks for the reply, The function is actually another part of the macro that will execute a copy of that row and then print. I have that portion created. The calc sheet has a number of rows, with eachrow containing a username and then data associated with the week of the year. I wish to have a printout of each user and then the associated data in a three column form. I have a macro that will print just the single line, but would like to see a macro run that will print, from the starting row all the usernames and data. Again, the number of username can vary throughout a year. So I don't want to edit a macro each time we are in need of a printout. Thanks to all
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT - 8 Hours Page 1 of 1

 Jump to: Select a forum OpenOffice.org Forums----------------Setup and TroubleshootingOpenOffice.org WriterOpenOffice.org CalcOpenOffice.org ImpressOpenOffice.org DrawOpenOffice.org MathOpenOffice.org BaseOpenOffice.org Macros and APIOpenOffice.org Code Snippets Community Forums----------------General DiscussionSite Feedback
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum