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

Solved! Who knows a makro to add data to the next empty cell

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


Joined: 20 May 2012
Posts: 4
Location: Netherlands

PostPosted: Sun May 20, 2012 6:14 am    Post subject: Solved! Who knows a makro to add data to the next empty cell Reply with quote

what macro (or fomula) can I use to add data, to the next empty cell in a collum in another sheet

I have just registred to this forum, and have looked through a lot of postings allready, but have stopped searching before I'm at page 350..........

Can someone help me with this:
I am looking for a (formula or) macro that (with the push on a "button") automaticaly copies the new input from the sheet that I work on to the next empty cell in a collum on another sheet (same document)
I use macro's and buttons all the time but cannot yet trick the OOOprogram to do this action

In this way I like to fill in, for instance, an address record form on sheet one with new data, and end up with list of all input neatly distributed over the next row on the next sheet.

My sister had programmed me such a macro in Excel (she is an Excel pro) but this naturaly does not work in OOO (of which she knows nothing....)


Last edited by microjo on Tue May 22, 2012 11:51 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Sun May 20, 2012 6:59 am    Post subject: Reply with quote

If you would simply search the right forum, you could find dozends of snippets.
_________________
Rest in peace, oooforum.org
Get help on https://forum.openoffice.org
Back to top
View user's profile Send private message
microjo
Newbie
Newbie


Joined: 20 May 2012
Posts: 4
Location: Netherlands

PostPosted: Sun May 20, 2012 11:20 am    Post subject: Reply with quote

Thanks Villeroy, for this answer, I have been searching for a while allready, and even with your suggested search help, I still have no lead to a solution of this question.
So if you dont mind, do I like to wait for a more direct help.

In the meantime am I looking through the JAVA programmers manual to see for a "background" solution
Back to top
View user's profile Send private message Visit poster's website
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Sun May 20, 2012 11:53 am    Post subject: Reply with quote

Do us all a favour and use Excel.
_________________
Rest in peace, oooforum.org
Get help on https://forum.openoffice.org
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Sun May 20, 2012 12:34 pm    Post subject: Reply with quote

Open a new Calc document. In Sheet2 cell A1 type "Input Data". In any cell in Sheet1 type new data and, with that cell still active, run the macro below.
Code:
Sub CopyInput
oSel = ThisComponent.currentSelection.String
oSheet = ThisComponent.Sheets(1) 'Sheet2
oCur = oSheet.createCursor
oCur.gotoEndOfUsedArea(false)
oCell = oSheet.getCellByPosition(0,oCur.RangeAddress.EndRow+1)
oCell.String = oSel
End Sub
Back to top
View user's profile Send private message
microjo
Newbie
Newbie


Joined: 20 May 2012
Posts: 4
Location: Netherlands

PostPosted: Sun May 20, 2012 1:01 pm    Post subject: Reply with quote

Thank you JohnV,

This works!, This is a fast step in the good direction for my project.

I hardly dare to ask, but could this macro be extended to copy a row to the next empty row in another sheet? (always starting in column A)

Incase you should need help with some thing from my hobby, I will do the most to help you. (see www button)
Back to top
View user's profile Send private message Visit poster's website
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Tue May 22, 2012 9:13 am    Post subject: Reply with quote

Code:
Sub CopyRow
oDoc = ThisComponent
oCell = ThisComponent.currentSelection
oSheet = oDoc.Sheets(oCell.RangeAddress.Sheet)
Row = oCell.RangeAddress.EndRow
oCur = oSheet.createCursor
oCur.gotoEndOfUsedArea(false)
REM Get columns in widest row.
Col = oCur.RangeAddress.EndColumn
oRange = oSheet.GetCellRangeByPosition(0,Row,Col,Row)
fa = oRange.getFormulaArray
oSheet = ThisComponent.Sheets(1) 'Sheet2
oCur = oSheet.createCursor
oCur.gotoEndOfUsedArea(false)
oRange = oSheet.getCellRangeByPosition(0,oCur.RangeAddress.EndRow+1,Col,oCur.RangeAddress.EndRow+1)
oRange.setFormulaArray(fa)
End Sub
Back to top
View user's profile Send private message
microjo
Newbie
Newbie


Joined: 20 May 2012
Posts: 4
Location: Netherlands

PostPosted: Tue May 22, 2012 11:50 am    Post subject: Solved! Reply with quote

JohnV you are Great!
Thank you so much, this set of macro's do all the tricks that I want to do.

Remember my www, and mail me if you have a question in my area.

Microjo
Back to top
View user's profile Send private message Visit poster's website
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