Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default CurrentRegion works different in the Editor than in the workbook

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default CurrentRegion works different in the Editor than in the workbook

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default CurrentRegion works different in the Editor than in the workbo

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
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
sharing a workbook with one editor artemis1027 Excel Discussion (Misc queries) 6 August 17th 07 06:20 AM
formula that works in a different workbook Jude Reason Excel Worksheet Functions 5 January 21st 07 03:34 PM
Excel Addin works that works on a template workbook s.jay_k Excel Programming 0 February 15th 06 07:31 PM
Disabling Visual Basic Editor After Protecting Worksheet/Workbook Reggie Excel Programming 4 January 27th 06 01:37 AM
Macro works in one workbook but not in another sungen99[_42_] Excel Programming 6 January 26th 06 06:25 PM


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