LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default returning data of type range; error 91

A subroutine calls a function which is supposed to return data of type
"range". The
function fails with error 91. I suspect I am not differentiating a
"reference" to data from actual data. Here is the code:

Sub A()
Dim b as Range
Dim i as long
set b = BRange()
i = b.Columns.Count
end Sub

Function BRange() as Range
Dim aRange as Range
Dim i as long

set aRange = Application.InputBox(prompt:="select table",Type:=8)
i = aRange.columns.count
BRange = aRange
end Function

NOTES: Code fails when I attempt to assign aRange to BRange. I get a
run-time error of '91' - "object variable or with block variable not set".
I should point out that the Application.InputBox DOES return the range as I
CAN read at least one value through the variable, i, within the
function,BRange. (i can read the rest but kept this example simple by
omitting them)

please help me understand what I am doing wrong. I seem to be ignorant
about something and hence can't overcome this error
 
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
Type Mismatch error while checking range value illini_99[_2_] Excel Programming 3 August 21st 08 06:36 PM
Returning data from within a date range Cdn Gas Guy Excel Programming 10 January 16th 08 12:06 AM
Returning value from a range of data tinagi Excel Discussion (Misc queries) 1 February 20th 06 03:05 AM
Strange data type error johnsday Excel Programming 7 January 20th 06 04:08 PM
Type Mismatch error & subscript out of range error Jeff Wright[_2_] Excel Programming 3 May 14th 05 07:14 PM


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