OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

In need of advice on macro to step thru column of data

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc
View previous topic :: View next topic  
Author Message
BBrinson
General User
General User


Joined: 20 May 2005
Posts: 6

PostPosted: Tue May 31, 2005 10:11 am    Post subject: In need of advice on macro to step thru column of data Reply with quote

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
Back to top
View user's profile Send private message
TheReads
General User
General User


Joined: 17 Jan 2005
Posts: 8
Location: England

PostPosted: Tue May 31, 2005 11:57 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
BBrinson
General User
General User


Joined: 20 May 2005
Posts: 6

PostPosted: Tue May 31, 2005 12:54 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group