Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function returns Range -- error 91
This function...
Function Range4(R1 As Integer, C1 As Integer, R2 As Integer, C2 As Integer) As Range Set Range4 = Range(Cells(R1, C1), Cells(R2, C2)) End Function .... works fine through the assignment to Range4 (gets the correct range), but hangs at the End Funciton line with Run-time error '91': Object variable or With block variable not set What am I doing wrong? I've tried: adding "ActiveSheet." to everything; an auxilliary Range variable; searching this group. Thanks. --David. PS: Anybody know a better way to construct a simple rectangular range using numeric arguments rather than string addresses. But I'd still like to know why this function fails. It fails even if I assign a very simple range to Range4, like ActiveCell. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function returns Range -- error 91
When I called it using
Set r = Range4(1, 2, 3, 4) it worked fine. What values are you passing? -- HTH RP (remove nothere from the email address if mailing direct) wrote in message oups.com... This function... Function Range4(R1 As Integer, C1 As Integer, R2 As Integer, C2 As Integer) As Range Set Range4 = Range(Cells(R1, C1), Cells(R2, C2)) End Function ... works fine through the assignment to Range4 (gets the correct range), but hangs at the End Funciton line with Run-time error '91': Object variable or With block variable not set What am I doing wrong? I've tried: adding "ActiveSheet." to everything; an auxilliary Range variable; searching this group. Thanks. --David. PS: Anybody know a better way to construct a simple rectangular range using numeric arguments rather than string addresses. But I'd still like to know why this function fails. It fails even if I assign a very simple range to Range4, like ActiveCell. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function returns Range -- error 91
In a general module, this worked fine for me:
Function Range4(R1 As Integer, C1 As Integer, R2 As Integer, C2 As Integer) As Range Set Range4 = Range(Cells(R1, C1), Cells(R2, C2)) End Function Sub Tester3() Dim i1 As Integer, i2 As Integer Dim j1 As Integer, j2 As Integer i1 = 10 i2 = 20 j1 = 5 j2 = 26 MsgBox Range4(i1, j1, i2, j2).Address End Sub -- Regards, Tom Ogilvy wrote in message oups.com... This function... Function Range4(R1 As Integer, C1 As Integer, R2 As Integer, C2 As Integer) As Range Set Range4 = Range(Cells(R1, C1), Cells(R2, C2)) End Function ... works fine through the assignment to Range4 (gets the correct range), but hangs at the End Funciton line with Run-time error '91': Object variable or With block variable not set What am I doing wrong? I've tried: adding "ActiveSheet." to everything; an auxilliary Range variable; searching this group. Thanks. --David. PS: Anybody know a better way to construct a simple rectangular range using numeric arguments rather than string addresses. But I'd still like to know why this function fails. It fails even if I assign a very simple range to Range4, like ActiveCell. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function returns Range -- error 91
Hmmm... Well, I tried this on an entirely blank workbook, immediately
aftr rebooting my system... Function Range4(R1 As Integer, C1 As Integer, R2 As Integer, C2 As Integer) As Range Set Range4 = ActiveCell End Function Sub SetupStuff() Dim R As Range R = Range4(1, 2, 3, 5) End Sub .... and it still fails the same way. Obviously something is broken. Good news -- I can still program VBA. Bad news -- I'm stuck, and wondering what else what might go wrong? Any ideas? I'm using: VB 6.3; Excel 2002 SP3; WinXP Pro SP1; on a Dell Latitude. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function returns Range -- error 91
In your test code, you need to change
R = Range4(1, 2, 3, 5) to Set R = Range4(1, 2, 3, 5) "David Lewis" wrote in message oups.com... Hmmm... Well, I tried this on an entirely blank workbook, immediately aftr rebooting my system... Function Range4(R1 As Integer, C1 As Integer, R2 As Integer, C2 As Integer) As Range Set Range4 = ActiveCell End Function Sub SetupStuff() Dim R As Range R = Range4(1, 2, 3, 5) End Sub ... and it still fails the same way. Obviously something is broken. Good news -- I can still program VBA. Bad news -- I'm stuck, and wondering what else what might go wrong? Any ideas? I'm using: VB 6.3; Excel 2002 SP3; WinXP Pro SP1; on a Dell Latitude. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function returns Range -- error 91
Duh. Thanks!
--David. |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Function returns Range -- error 91
Duh!
Thanks!!! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
IF(AND(OR function returns #VALUE! error | Excel Worksheet Functions | |||
LINEST() function returns error. | Excel Discussion (Misc queries) | |||
Find function returns the #VALUE! error value | Excel Discussion (Misc queries) | |||
AVERAGE function returns #DIV/0! error | Excel Discussion (Misc queries) | |||
Named range returns 1004 error | Excel Programming |