#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Udf


Please,
i need this function to return formula to cell...not the value but
the formula...
thanks a lot

Public Function fnMonth(i As Integer)
fnMonth = "=Podklady!B" & 114 + i
End Functio

--
kontra
-----------------------------------------------------------------------
kontraa's Profile: http://www.excelforum.com/member.php...fo&userid=3302
View this thread: http://www.excelforum.com/showthread.php?threadid=53585

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Udf

Can't do it, that is altering the cell and a function cannot do that. You
could try an event procedure.

'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
'-----------------------------------------------------------------
Const WS_RANGE As String = "H1:H10"

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If IsNumeric(.Value) Then
.Formula = "=Podklady!B" & 114 + .Value
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"kontraa" wrote in
message ...

Please,
i need this function to return formula to cell...not the value but
the formula...
thanks a lot

Public Function fnMonth(i As Integer)
fnMonth = "=Podklady!B" & 114 + i
End Function


--
kontraa
------------------------------------------------------------------------
kontraa's Profile:

http://www.excelforum.com/member.php...o&userid=33028
View this thread: http://www.excelforum.com/showthread...hreadid=535859



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Udf

kontraa,
Is this what you mean ?

In sheet1, range A1=GetFormula(5)

Public Function GetFormula(argOffset As Long) As String
With Sheet2.Range("A1")
GetFormula = .Offset(argOffset, 1).Formula
End With
End Function

But I suspect there are better way of achieving your goal.

NickHK

"kontraa" wrote in
message ...

Please,
i need this function to return formula to cell...not the value but
the formula...
thanks a lot

Public Function fnMonth(i As Integer)
fnMonth = "=Podklady!B" & 114 + i
End Function


--
kontraa
------------------------------------------------------------------------
kontraa's Profile:

http://www.excelforum.com/member.php...o&userid=33028
View this thread: http://www.excelforum.com/showthread...hreadid=535859



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"