Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Using User-Defined Functions in Cells

UDF's called from a worksheet cell can't change other cells. It can only return
a value to the cell with the formula in it. (With very minor exceptions.)

Trent Argante wrote:

In cell A4 I have the the user-defined function of
=IF(B4<"", PPAPNumber(F4),"")
The user-defined procedure "PPAPNumber", in turn, calls this:

Private Function f_GetSeqNumber(iYear As Integer) As Integer
' CORTPA:DC.J(510):20070612T2107E:20070612t2210e
Dim r As Range
Dim rngSeq As Range
Set rngSeq = Range("PPAPSeqYear")

' Find the passed year in named-range 'PPAPSeqYear'
For Each r In rngSeq.Cells
' Test for matching year
If r.Value = iYear Then
' Select cell in named-range that has matching year
'Placing the Stop command here works.
r.Select 'This line is ignored by the procedure for unknown
reason
'Placing a the Stop command here DOES NOT work! WHY???
' Assign the value of the cell, _
one column to the right of the matching cell, _
to the function
'This line is ignored by the procedure for unknown reason
f_GetSeqNumber = r.Offset(0, 1).Value
' Incrementthe value of the cell, _
one column to the right of the matching cell, _
by 1
'This line is ignored by the procedure for unknown reason
r.Offset(0, 1).Value = r.Offset(0, 1).Value + 1
Exit For
End If
Next
End Function

My dilemmas are stated in the code's comments.
TIA
Trent Argante
[DC.J(510)]

*** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using User-Defined Functions in Cells NickHK[_3_] Excel Programming 2 June 13th 07 03:36 PM
User Defined Functions - Help Text - Make it Easy for the User Andibevan[_2_] Excel Programming 4 March 17th 05 09:51 AM
User Defined Functions Chris Gorham Excel Programming 1 November 24th 04 04:04 PM
user defined functions Alexander Bogomolny Excel Programming 4 July 25th 04 07:54 PM
excel functions and User defined functions Kanan Excel Programming 4 May 20th 04 11:21 PM


All times are GMT +1. The time now is 01:48 PM.

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

About Us

"It's about Microsoft Excel"