Thread
:
is it possible to store formula under a UDF
View Single Post
#
1
Posted to microsoft.public.excel.programming
Don Guillett
external usenet poster
Posts: 10,124
is it possible to store formula under a UDF
A couple of typos
set rng = .Range(T2:T2000)
set rng = .Range("T2:T2000")
Also, rng.formula= to the end is ONE line.
--
Don Guillett
SalesAid Software
"been drilbled to 2007" wrote
in message ...
Sir Tom,
really i am stupid with this language, i copy and paste the code and there
is an alarming pop-up window with an exclamation "!" mark..it saya Compile
error: Invalid outside procedure....
about the T1,
the formula i gave is first located in T2, and then i drag it down to
populate the formula under a column..
since my co-office personnel are more dumbererer than i am in terms of
excel, that's why i need a macro that will enable them to hit or run a
macro...more easier for me to explain...
otherwise, i will have to provide them a neverending explanation of what
are
those functions doing in one formula....
thanks for your enlightenment ,
4pinoyjunior
--
*****
birds of the same feather flock together..
"Tom Ogilvy" wrote:
With Worksheets("Sheet1")
set rng = .Range(T2:T2000)
End With
rng.Formula =
"=IF(T1=LOOKUP(MAX(holidays),holidays),T1,IF(AND(W EEKDAY(T1)=1,LOOKUP(T1,holidays)=T1),T1+1,IF(OR(AN D(LOOKUP(T1,holidays)=T1,WEEKDAY(T1)=6),AND(LOOKUP (T1+2,holidays)=T1+2)),T1+1,MIN(T1+(LOOKUP(WEEKDAY (T1),{1,2,3,4,5,6,7},{7,6,5,4,3,2,1})),INDEX(holid ays,MATCH(T1,holidays,ROW(T1))+1)))))"
or
set rng = Range("N_WD")
then as above.
if you don't want the formula to refer to the cell above it, then you
would
need to add some dollar signs to fix the references. I have no idea what
you
are doing, so I can't say.
--
Regards,
Tom Ogilvy
I have no idea what you mean by
"been drilbled to 2007" wrote:
i'm sorry Sir Tom,
i'm a real junior in terms of creating a macro.
i've seen in help files a lot of references about which methods, or
whatever....
can you be patient for this one by giving me a copy-paste module
the formula i had to paste on T2:T2000 or more..and run the macro and
then
the range T1:T2000 or more will have a defined "N_WD"
T1 is linked to the first cell of column range name "holidays"
thanks for enlightenment
4pinoyjunior
--
*****
birds of the same feather flock together..
"Tom Ogilvy" wrote:
If the range Holidays is already defined as a workbook level name, it
makes
no difference where it is located
With Worksheets("Sheet1")
set rng = .Range(.Cells(1,"S"),.Cells(1,"S").End(xldown))
End With
rng.Formula =
"=IF(T1=LOOKUP(MAX(holidays),holidays),T1,IF(AND(W EEKDAY(T1)=1,LOOKUP(T1,holidays)=T1),T1+1,IF(OR(AN D(LOOKUP(T1,holidays)=T1,WEEKDAY(T1)=6),AND(LOOKUP (T1+2,holidays)=T1+2)),T1+1,MIN(T1+(LOOKUP(WEEKDAY (T1),{1,2,3,4,5,6,7},{7,6,5,4,3,2,1})),INDEX(holid ays,MATCH(T1,holidays,ROW(T1))+1)))))"
--
Regards,
Tom Ogilvy
"been drilbled to 2007" wrote:
Hi, Sir Tom,
this is the formula
=IF(T1=LOOKUP(MAX(holidays),holidays),T1,IF(AND(WE EKDAY(T1)=1,LOOKUP(T1,holidays)=T1),T1+1,IF(OR(AND (LOOKUP(T1,holidays)=T1,WEEKDAY(T1)=6),AND(LOOKUP( T1+2,holidays)=T1+2)),T1+1,MIN(T1+(LOOKUP(WEEKDAY( T1),{1,2,3,4,5,6,7},{7,6,5,4,3,2,1})),INDEX(holida ys,MATCH(T1,holidays,ROW(T1))+1)))))
T1 is a cell address
Named range : holidays (column range)
Can it be possible that i can run the macro say in sheet1, while
the
holidays are in sheet2.
thanks for enlightenment
4pinoyjunior
--
*****
birds of the same feather flock together..
"Tom Ogilvy" wrote:
Private Sub CommandButton1_click()
Range("Name1").Formula = "=Sum(A1:F1)"
End Sub
--
Regards,
Tom Ogilvy
"been drilbled to 2007" wrote:
Hi Sir Don,
sorry for my poor english, maybe what i mean is a macro to
trigger the
embedding of a long formula under a named range...
wherein the formula is built with different excel fx and the
cells are with
defined names...
i never know anything about this
thanks
4pinoyjunior
--
*****
birds of the same feather flock together..
"Don Guillett" wrote:
You need to tell us what you are talking about. A UDF is
meant to create a
custom formula to return a value.
--
Don Guillett
SalesAid Software
"been drilbled to 2007"
wrote
in message
...
hello,
i got some few formulas that i need to be stored under a
UDF. please
respond
if you can help me with this.
dribler2
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett