Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Function limitations?

Can I use the property CurrentRegion and then a Range.Rows.Count inside a
function? Inside a Subrutine it works properly but inside a function the
counting gives 0 ... ???!!!

The code is

Function MediaCriticitÃ*(Domanda As Integer, Sottodomanda As String) As Double
Dim Nr, Nc As Integer
MacroMedia = 0
Record = 1
Set Destinaz = Worksheets("Calcoli_TMP").Range("A1")
With Sheets("Dati").Cells(1, 1)
Set Zc = .CurrentRegion
Nr = Zc.Rows.Count - 1
Nc = Zc.Columns.Count
Set RecCorr = Zc.Resize(1)
RecCorr.Copy Destinaz
For i = 1 To Nr
Set RecCorr = RecCorr.Offset(1)
If (RecCorr.Cells(4) = Domanda) And (RecCorr.Cells(5) =
Sottodomanda) And (RecCorr.Cells(6) < 0) Then
Record = Record + 1
If (RecCorr.Cells(7) = 1) Then
MacroMedia = MacroMedia + 1
Set Destinaz = Destinaz.Offset(1)
RecCorr.Copy Destinaz
End If
End If
Next

End With
MacroMedia = MacroMedia / Record
End Function

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Function limitations?

but inside a function the
counting gives 0 ... ???!!!


that would mean no. (function used in a worksheet. function used in VBA
would be no different than a subroutine)

--
Regards,
Tom Ogilvy



"Enrico" wrote in message
...
Can I use the property CurrentRegion and then a Range.Rows.Count inside a
function? Inside a Subrutine it works properly but inside a function the
counting gives 0 ... ???!!!

The code is

Function MediaCriticità(Domanda As Integer, Sottodomanda As String) As

Double
Dim Nr, Nc As Integer
MacroMedia = 0
Record = 1
Set Destinaz = Worksheets("Calcoli_TMP").Range("A1")
With Sheets("Dati").Cells(1, 1)
Set Zc = .CurrentRegion
Nr = Zc.Rows.Count - 1
Nc = Zc.Columns.Count
Set RecCorr = Zc.Resize(1)
RecCorr.Copy Destinaz
For i = 1 To Nr
Set RecCorr = RecCorr.Offset(1)
If (RecCorr.Cells(4) = Domanda) And (RecCorr.Cells(5) =
Sottodomanda) And (RecCorr.Cells(6) < 0) Then
Record = Record + 1
If (RecCorr.Cells(7) = 1) Then
MacroMedia = MacroMedia + 1
Set Destinaz = Destinaz.Offset(1)
RecCorr.Copy Destinaz
End If
End If
Next

End With
MacroMedia = MacroMedia / Record
End Function



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Function limitations?

If you are calling this function from a formula in a worksheet cell, the .Copy
statements are not legal.

On Fri, 11 Feb 2005 08:13:05 -0800, Enrico wrote:

Can I use the property CurrentRegion and then a Range.Rows.Count inside a
function? Inside a Subrutine it works properly but inside a function the
counting gives 0 ... ???!!!

The code is

Function MediaCriticità(Domanda As Integer, Sottodomanda As String) As Double
Dim Nr, Nc As Integer
MacroMedia = 0
Record = 1
Set Destinaz = Worksheets("Calcoli_TMP").Range("A1")
With Sheets("Dati").Cells(1, 1)
Set Zc = .CurrentRegion
Nr = Zc.Rows.Count - 1
Nc = Zc.Columns.Count
Set RecCorr = Zc.Resize(1)
RecCorr.Copy Destinaz
For i = 1 To Nr
Set RecCorr = RecCorr.Offset(1)
If (RecCorr.Cells(4) = Domanda) And (RecCorr.Cells(5) =
Sottodomanda) And (RecCorr.Cells(6) < 0) Then
Record = Record + 1
If (RecCorr.Cells(7) = 1) Then
MacroMedia = MacroMedia + 1
Set Destinaz = Destinaz.Offset(1)
RecCorr.Copy Destinaz
End If
End If
Next

End With
MacroMedia = MacroMedia / Record
End Function


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
If function limitations help fischerjp Excel Discussion (Misc queries) 7 May 3rd 10 08:41 PM
Alternative to the limitations of the 'IF' function in Excel? Charles Excel Worksheet Functions 3 March 7th 09 02:24 AM
function nesting limitations Bitter Clinger New Users to Excel 5 November 3rd 08 01:40 AM
Indirect function - Limitations Ken Cobler Excel Worksheet Functions 2 September 16th 05 04:59 PM
function cell range limitations AXA Excel Worksheet Functions 3 January 30th 05 11:09 PM


All times are GMT +1. The time now is 02:14 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"