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

Help with Calc and inserting new rows

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
Gorky
Newbie
Newbie


Joined: 24 Apr 2007
Posts: 2

PostPosted: Tue Apr 24, 2007 4:42 am    Post subject: Help with Calc and inserting new rows Reply with quote

Hello,

I have a really big problem which I do not know how to fix. Here is the problem:

- I have data cells with formulas
- Now i need to record a macro that would insert a new row, before my first data row, but the new row should have the same formulas as the next row but no data.

- One formula is: =IF(ISNUMBER(B8 );B8+1;1) and it determinate the "ID". The B8 is the row before that. But when I insert a new row before row B9 it should rename B8 to B9 but it doesn't. All next rows are given the right numbers but the first one still calls B8 which is now not a row above it.

If anyone understands me : ) please, I really need some help.

Cheers,
Gorky
Back to top
View user's profile Send private message
noranthon
Super User
Super User


Joined: 07 Jul 2005
Posts: 3318

PostPosted: Tue Apr 24, 2007 4:48 am    Post subject: Reply with quote

Would a simple solution be to copy the formulas rather than re-enter them?
_________________
search forum by month
Back to top
View user's profile Send private message
Gorky
Newbie
Newbie


Joined: 24 Apr 2007
Posts: 2

PostPosted: Tue Apr 24, 2007 5:18 am    Post subject: Reply with quote

noranthon wrote:
Would a simple solution be to copy the formulas rather than re-enter them?


I am copying them. The problem is I gues with relative calling. Because I need to tell macro somehow that when I start it, it should always insert new row at row 8, not where mouse pointer is... Thats one problem.
Back to top
View user's profile Send private message
Mark B
Super User
Super User


Joined: 16 Feb 2007
Posts: 852
Location: Lincolnshire, UK

PostPosted: Tue Apr 24, 2007 8:26 am    Post subject: Reply with quote

Hi

Once your macro has inserted the new row you can use something like:
Code:

oSheet = thiscomponent.sheets(0)
oRange = oSheet.getCellRangeByPosition(0,1,0,20)
oRange.fillAuto(TO_BOTTOM,1)

This autofills from A2 down to A19

If you're wondering about the parameters for fillauto have a look at http://api.openoffice.org/docs/common/ref/com/sun/star/sheet/XCellSeries.html

Mark
_________________
Mark B's Articles
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
noranthon
Super User
Super User


Joined: 07 Jul 2005
Posts: 3318

PostPosted: Tue Apr 24, 2007 6:43 pm    Post subject: Reply with quote

To insert one new row at row 9, you can use something like this:
Code:
'you must have a definition of oSheet
oSheet.Rows.insertByIndex( 8, 1 ) ' row 9, one row

_________________
search forum by month
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 Macros and API 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