Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default Sending data back to parameters

Hi every1!!!

Need to know if this can be done. Here is my problem.

Ive created a custum function that takes-in parameters from a few cells on
same row
its being called from.

With those parameters i do some calculations and find what needs to be found.
So far so good.

Lets say i find the following answer inside this function of mine: 45
Could i then redirect that answer to one of my parameter cell.

Senario:

Columns

L M N AF
0 0 0 (my function is here)


Lets say my funct. says that when L,M,N =0 then M should equal to : 4

Can i asign that 4 to M while still in my function.

Can this be done?

Thx for your help

PAtrick



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Sending data back to parameters

That should be OK with just one provision. The function can not be used
directly in the cell of a spreadsheet. Declare the function private so that
it can only be accessed in code and not through the list of functions in
Excel.

HTH

"Patrick" wrote:

Hi every1!!!

Need to know if this can be done. Here is my problem.

Ive created a custum function that takes-in parameters from a few cells on
same row
its being called from.

With those parameters i do some calculations and find what needs to be found.
So far so good.

Lets say i find the following answer inside this function of mine: 45
Could i then redirect that answer to one of my parameter cell.

Senario:

Columns

L M N AF
0 0 0 (my function is here)


Lets say my funct. says that when L,M,N =0 then M should equal to : 4

Can i asign that 4 to M while still in my function.

Can this be done?

Thx for your help

PAtrick



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Sending data back to parameters

Patrick

simple answer is no. A function can only return a value, not affect other
cells or formatting ... or the Excel environment in general.

Regards

Trevor


"Patrick" wrote in message
...
Hi every1!!!

Need to know if this can be done. Here is my problem.

Ive created a custum function that takes-in parameters from a few cells on
same row
its being called from.

With those parameters i do some calculations and find what needs to be
found.
So far so good.

Lets say i find the following answer inside this function of mine: 45
Could i then redirect that answer to one of my parameter cell.

Senario:

Columns

L M N AF
0 0 0 (my function is here)


Lets say my funct. says that when L,M,N =0 then M should equal to : 4

Can i asign that 4 to M while still in my function.

Can this be done?

Thx for your help

PAtrick





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Sending data back to parameters

I agree with you in general. A function should not change anything within its
environment. No Side Effects. That being said, Excel does not keep you from
creating side effects. Not to mention so long as this function is private and
not accessible directly through excel, then there should be no problem. My
big question for Patrick would be what is this function supposed to return.
As a guess this is not a function at all but a sub procedure where nothing is
being returned.

I personally ensure that my functions do not create side effects, right down
to ensuring that the acitive cell is not moved... I assume you live by the
same rule and I like your coding discipline...

"Trevor Shuttleworth" wrote:

Patrick

simple answer is no. A function can only return a value, not affect other
cells or formatting ... or the Excel environment in general.

Regards

Trevor


"Patrick" wrote in message
...
Hi every1!!!

Need to know if this can be done. Here is my problem.

Ive created a custum function that takes-in parameters from a few cells on
same row
its being called from.

With those parameters i do some calculations and find what needs to be
found.
So far so good.

Lets say i find the following answer inside this function of mine: 45
Could i then redirect that answer to one of my parameter cell.

Senario:

Columns

L M N AF
0 0 0 (my function is here)


Lets say my funct. says that when L,M,N =0 then M should equal to : 4

Can i asign that 4 to M while still in my function.

Can this be done?

Thx for your help

PAtrick






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default Sending data back to parameters

In article ,
says...
I agree with you in general. A function should not change anything within its
environment. No Side Effects. That being said, Excel does not keep you from
creating side effects. Not to mention so long as this function is private and


Maybe, you can share an example of a user defined function that can
change which cell is the active cell and/or change contents of
arguments that are other cell references...

If you'd like a 'for instance' how about: In cell B1 I'd like to enter
=JTUDF(A1) and have function change the content of A1 and move the
active cell to J1.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
I agree with you in general. A function should not change anything within its
environment. No Side Effects. That being said, Excel does not keep you from
creating side effects. Not to mention so long as this function is private and
not accessible directly through excel, then there should be no problem. My
big question for Patrick would be what is this function supposed to return.
As a guess this is not a function at all but a sub procedure where nothing is
being returned.

I personally ensure that my functions do not create side effects, right down
to ensuring that the acitive cell is not moved... I assume you live by the
same rule and I like your coding discipline...

"Trevor Shuttleworth" wrote:

Patrick

simple answer is no. A function can only return a value, not affect other
cells or formatting ... or the Excel environment in general.

Regards

Trevor


"Patrick" wrote in message
...
Hi every1!!!

Need to know if this can be done. Here is my problem.

Ive created a custum function that takes-in parameters from a few cells on
same row
its being called from.

With those parameters i do some calculations and find what needs to be
found.
So far so good.

Lets say i find the following answer inside this function of mine: 45
Could i then redirect that answer to one of my parameter cell.

Senario:

Columns

L M N AF
0 0 0 (my function is here)


Lets say my funct. says that when L,M,N =0 then M should equal to : 4

Can i asign that 4 to M while still in my function.

Can this be done?

Thx for your help

PAtrick









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 339
Default Sending data back to parameters


"Patrick" wrote in message
...
Hi every1!!!

Need to know if this can be done. Here is my problem.

Ive created a custum function that takes-in parameters from a few cells on
same row
its being called from.

With those parameters i do some calculations and find what needs to be

found.
So far so good.

Lets say i find the following answer inside this function of mine: 45
Could i then redirect that answer to one of my parameter cell.

Senario:

Columns

L M N AF
0 0 0 (my function is here)


Lets say my funct. says that when L,M,N =0 then M should equal to : 4

Can i asign that 4 to M while still in my function.

Can this be done?

Thx for your help

PAtrick


Not from within a cell function. You should use the Worksheet_Change event
to do this.

/Fredrik


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default Sending data back to parameters

Here's a copy of my function as is.

If my 3 main columns L,M and N are empty it needs to find these values.
Now my client would like to see these values, hence the question about
sending the info back to a parameter.

Public Function Assign_L75_Value(ByVal var_air As String, _
ByVal var_L75 As String, ByVal var_style As String, _
ByVal var_tabName As String, ByVal var_ThermalS As String, _
ByVal var_FL75 As String, ByVal var_CLStr As String)

Dim CrackLTH As Double
Dim check As Boolean
Dim var_CLStrucValue As Double
Dim var_Final_L75 As String
Dim foundL75 As Double

check = checkEmptyAsignL75(var_style, var_ThermalS, var_air, var_L75)

If check Then
Assign_L75_Value = "***"
Exit Function
ElseIf var_FL75 = "-R-" Then
Assign_L75_Value = "-R-"
Exit Function
End If

'Find the value based on crack lenght and Air column value.
CrackLTH = GetCrackLenghValue(var_style, var_tabName, var_ThermalS)
If CrackLTH = 0 Then
Assign_L75_Value = "***"
Exit Function
End If

'Check if value exist in the M column, if its the case it means that
'the user actually entered a value in the L and N column.
'Here there's another function in the M column that takes values from
'The L and N columns. It returns '***' when no values are found in these 2
cols.
'So i only check for the '***'if there there it means that its empty.

If var_L75 = "***" Then 'we need to back-fill
var_CLStrucValue = GetCrackLenghStrucValue(var_style, var_tabName)

'**** Over here could i copy this value back into the appropriate column.
'**** Thats my kestion.

'Get the L75 value based on category.
Select Case var_air
Case "A2"
foundL75 = 1.65 * var_CLStrucValue
Case "A3"
foundL75 = 0.55 * var_CLStrucValue
Case "FX"
foundL75 = 0.25 * var_CLStrucValue
End Select


var_Final_L75 = Application.Round(foundL75 * (CrackLTH / var_CLStrucValue),
3)
Assign_L75_Value = var_Final_L75


Else 'we can use values entered in L,M,N columns.
var_Final_L75 = Application.Round(CDbl(var_L75) * (CrackLTH /
CDbl(var_CLStr)), 3)
Assign_L75_Value = var_Final_L75
End If


End Function

Does it make any sence with the code...
thx again
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Sending data back to parameters

Looking at the function I would advise against it very strongly... Side
effects are a beast to deal with. It would be no fun at all if Sum changed
the source data that it was summing. The same is true here... If something
were to crash half way thoough, or there was an error in the logic... You
would be verrrryyyyyyy unhappy.

HTH

"Patrick" wrote:

Here's a copy of my function as is.

If my 3 main columns L,M and N are empty it needs to find these values.
Now my client would like to see these values, hence the question about
sending the info back to a parameter.

Public Function Assign_L75_Value(ByVal var_air As String, _
ByVal var_L75 As String, ByVal var_style As String, _
ByVal var_tabName As String, ByVal var_ThermalS As String, _
ByVal var_FL75 As String, ByVal var_CLStr As String)

Dim CrackLTH As Double
Dim check As Boolean
Dim var_CLStrucValue As Double
Dim var_Final_L75 As String
Dim foundL75 As Double

check = checkEmptyAsignL75(var_style, var_ThermalS, var_air, var_L75)

If check Then
Assign_L75_Value = "***"
Exit Function
ElseIf var_FL75 = "-R-" Then
Assign_L75_Value = "-R-"
Exit Function
End If

'Find the value based on crack lenght and Air column value.
CrackLTH = GetCrackLenghValue(var_style, var_tabName, var_ThermalS)
If CrackLTH = 0 Then
Assign_L75_Value = "***"
Exit Function
End If

'Check if value exist in the M column, if its the case it means that
'the user actually entered a value in the L and N column.
'Here there's another function in the M column that takes values from
'The L and N columns. It returns '***' when no values are found in these 2
cols.
'So i only check for the '***'if there there it means that its empty.

If var_L75 = "***" Then 'we need to back-fill
var_CLStrucValue = GetCrackLenghStrucValue(var_style, var_tabName)

'**** Over here could i copy this value back into the appropriate column.
'**** Thats my kestion.

'Get the L75 value based on category.
Select Case var_air
Case "A2"
foundL75 = 1.65 * var_CLStrucValue
Case "A3"
foundL75 = 0.55 * var_CLStrucValue
Case "FX"
foundL75 = 0.25 * var_CLStrucValue
End Select


var_Final_L75 = Application.Round(foundL75 * (CrackLTH / var_CLStrucValue),
3)
Assign_L75_Value = var_Final_L75


Else 'we can use values entered in L,M,N columns.
var_Final_L75 = Application.Round(CDbl(var_L75) * (CrackLTH /
CDbl(var_CLStr)), 3)
Assign_L75_Value = var_Final_L75
End If


End Function

Does it make any sence with the code...
thx again

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
sending parameters to a dll... ibbm Excel Discussion (Misc queries) 0 February 20th 08 05:56 PM
Sending a Picture to the back LanceP Excel Worksheet Functions 4 March 19th 07 04:20 PM
Counting number of forwarding and sending back Jaydubs Excel Discussion (Misc queries) 2 June 16th 06 09:26 AM
sending object to the back in excel workbook M Kirwin Excel Discussion (Misc queries) 1 January 12th 06 05:11 AM
Sending variable data to a web site to be computed then brought back to Excel David Excel Programming 0 April 27th 04 09:44 AM


All times are GMT +1. The time now is 06:33 AM.

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"