Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi all,
I have tried to use CurrentRegion to define a range, and it doesn't work in the workbook, but works in the editor. I have used it on a function, and the function doesn't get the right region when called from the worksheet, but it does from the Inmediate window. This is the function: Function Test() Dim rngData As Excel.Range Set rngData = ActiveWorkbook.Worksheets("Sheet1").Range("A1").Cu rrentRegion Test = rngData.Rows.Count End Function I have a region of 2 columns and 12 rows in A1 of sheet1, if I try the function in the inmediate window with ?Test(), it returns 12; If I use it on the workbook with =Test(), it returs 1. The version of Excel is 2003 SP1. Is there anything that I am doing wrong? I would like to know why it doesn't work. Miguel. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Miguel,
Unfortunately, the CurrentRegion property cannot be used successfully in a UDF. In a similar way, the SpecialCells method does not work correctly in a worksheet function. --- Regards, Norman "Miguel Zapico" wrote in message ... Hi all, I have tried to use CurrentRegion to define a range, and it doesn't work in the workbook, but works in the editor. I have used it on a function, and the function doesn't get the right region when called from the worksheet, but it does from the Inmediate window. This is the function: Function Test() Dim rngData As Excel.Range Set rngData = ActiveWorkbook.Worksheets("Sheet1").Range("A1").Cu rrentRegion Test = rngData.Rows.Count End Function I have a region of 2 columns and 12 rows in A1 of sheet1, if I try the function in the inmediate window with ?Test(), it returns 12; If I use it on the workbook with =Test(), it returs 1. The version of Excel is 2003 SP1. Is there anything that I am doing wrong? I would like to know why it doesn't work. Miguel. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, I didn't knew that and it was weird finding it for the first time.
Miguel. "Norman Jones" wrote: Hi Miguel, Unfortunately, the CurrentRegion property cannot be used successfully in a UDF. In a similar way, the SpecialCells method does not work correctly in a worksheet function. --- Regards, Norman "Miguel Zapico" wrote in message ... Hi all, I have tried to use CurrentRegion to define a range, and it doesn't work in the workbook, but works in the editor. I have used it on a function, and the function doesn't get the right region when called from the worksheet, but it does from the Inmediate window. This is the function: Function Test() Dim rngData As Excel.Range Set rngData = ActiveWorkbook.Worksheets("Sheet1").Range("A1").Cu rrentRegion Test = rngData.Rows.Count End Function I have a region of 2 columns and 12 rows in A1 of sheet1, if I try the function in the inmediate window with ?Test(), it returns 12; If I use it on the workbook with =Test(), it returs 1. The version of Excel is 2003 SP1. Is there anything that I am doing wrong? I would like to know why it doesn't work. Miguel. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
sharing a workbook with one editor | Excel Discussion (Misc queries) | |||
formula that works in a different workbook | Excel Worksheet Functions | |||
Excel Addin works that works on a template workbook | Excel Programming | |||
Disabling Visual Basic Editor After Protecting Worksheet/Workbook | Excel Programming | |||
Macro works in one workbook but not in another | Excel Programming |