Page 1 of 1

[Solved] Function to choose any cell by mouse as argument

Posted: Mon Oct 27, 2008 12:29 pm
by srimal
Welcome beginner. What is your question or comment?
Please try to briefly and clearly tell us: What you want, What you tried, and What happened.
-----------------------------------------------------------------------------------------------------------

hi all,
I wrote a function with three argument which has assigned to any cell address and pass the value.but has a problem,
what i want:
1> select my data out put cell [D5]
2> run my function using macro
3> inside function will ask what is the cell u want as argument..then user select a valid cells by mouse
4> out put will in D5

i need to complete 3rd step.

FUNCTION:
Function volume(a, b, c)
volume = a*b*c
End Function

Re: Function to choose any cell by mouse as argument

Posted: Mon Oct 27, 2008 12:58 pm
by Villeroy
http://www.oooforum.org/forum/viewtopic ... eselection
[Moved away from "Beginners" forum]

Re: Function to choose any cell by mouse as argument

Posted: Mon Oct 27, 2008 1:56 pm
by srimal
I tried above link ....once i select the cell range then suddenly appears a dialog box saying,

>> Title: exit macro:getTargetCellAddress
"Target needs to be on another sheet or behind/below selection"


what was cause for that?

regrds,
srimal

Re: Function to choose any cell by mouse as argument

Posted: Mon Oct 27, 2008 2:07 pm
by Villeroy
Read the code. It rejects to paste into the copied region.

Re: Function to choose any cell by mouse as argument

Posted: Mon Oct 27, 2008 2:18 pm
by srimal
thanx i did it.It copies the cell range as it is.

regrds,
srimal

Re: Function to choose any cell by mouse as argument [solved]

Posted: Mon Oct 27, 2008 2:32 pm
by Villeroy
The macro copies the tiles of visible ranges to another place. In case of no hidden columns nor rows it copies the selected range.
The genreic part you need for your own stuff is

Code: Select all

Private sRangeSelection$,bRangeSelecting As Boolean
'return a valid com.sun.star.table.CellRangeAddress from a user's range-selection (or Empty)
Function getRangeSelectionAddress(oController,sInitial$,sTitle$,bAutoClose as Boolean) 
[...]
End Function
It returns a com.sun.star.table.CellRangeAddress if the user selected a range. It returns Basic type Empty if the user canceled. You've got to pass the spreadsheet-controller to pick from a default selection as string-address (A1:D4 or empty string), a title for the box and if a single click on the sheet is enough to close the selection box.