Thread: Udf
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
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