| View previous topic :: View next topic |
| Author |
Message |
microjo Newbie

Joined: 20 May 2012 Posts: 4 Location: Netherlands
|
Posted: Sun May 20, 2012 6:14 am Post subject: Solved! Who knows a makro to add data to the next empty cell |
|
|
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 |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Sun May 20, 2012 6:59 am Post subject: |
|
|
If you would simply search the right forum, you could find dozends of snippets. _________________ Rest in peace, oooforum.org
Get help on http://forum.openoffice.org |
|
| Back to top |
|
 |
microjo Newbie

Joined: 20 May 2012 Posts: 4 Location: Netherlands
|
Posted: Sun May 20, 2012 11:20 am Post subject: |
|
|
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 |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Sun May 20, 2012 11:53 am Post subject: |
|
|
Do us all a favour and use Excel. _________________ Rest in peace, oooforum.org
Get help on http://forum.openoffice.org |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8984 Location: Lexinton, Kentucky, USA
|
Posted: Sun May 20, 2012 12:34 pm Post subject: |
|
|
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 |
|
 |
microjo Newbie

Joined: 20 May 2012 Posts: 4 Location: Netherlands
|
Posted: Sun May 20, 2012 1:01 pm Post subject: |
|
|
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 |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8984 Location: Lexinton, Kentucky, USA
|
Posted: Tue May 22, 2012 9:13 am Post subject: |
|
|
| 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 |
|
 |
microjo Newbie

Joined: 20 May 2012 Posts: 4 Location: Netherlands
|
Posted: Tue May 22, 2012 11:50 am Post subject: Solved! |
|
|
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 |
|
 |
|