Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Range object evaluates to Range.value, or Range object

In most equations, when a Range object shows up in an expression on
the right hand side of the assignment operator "=", the range object's
value is used. I'm interested in assigning a range object to a
variable that has been dim'd as type Range.

Where can one find the rules that govern what objects evaluate to when
they show up in expressions?

Also, in many cases, things like Range are used in the documentation
to describe a Range object as well as a collection of range objects.
Where in the documentation does it describe how the word Range is
interpretted in (say) a Dim statement? What about rules governing
whether a collection is returned in evaluating an expression, or
whether a default object within the collection is returned?

Thanks. (I'm using Office 2003)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Range object evaluates to Range.value, or Range object

Paul,

You need to use Set:

Dim objRange As Range
Set objRange = Range("A1")
Msgbox objRange.Address & " is " & objRange.Value

HTH,
Bernie
MS Excel MVP


wrote in message
...
In most equations, when a Range object shows up in an expression on
the right hand side of the assignment operator "=", the range object's
value is used. I'm interested in assigning a range object to a
variable that has been dim'd as type Range.

Where can one find the rules that govern what objects evaluate to when
they show up in expressions?

Also, in many cases, things like Range are used in the documentation
to describe a Range object as well as a collection of range objects.
Where in the documentation does it describe how the word Range is
interpretted in (say) a Dim statement? What about rules governing
whether a collection is returned in evaluating an expression, or
whether a default object within the collection is returned?

Thanks. (I'm using Office 2003)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Range object evaluates to Range.value, or Range object

Paul,

You need to use Set:

Dim objRange As Range
Set objRange = Range("A1")
Msgbox objRange.Address & " is " & objRange.Value

HTH,
Bernie
MS Excel MVP


wrote in message
...
In most equations, when a Range object shows up in an expression on
the right hand side of the assignment operator "=", the range object's
value is used. I'm interested in assigning a range object to a
variable that has been dim'd as type Range.

Where can one find the rules that govern what objects evaluate to when
they show up in expressions?

Also, in many cases, things like Range are used in the documentation
to describe a Range object as well as a collection of range objects.
Where in the documentation does it describe how the word Range is
interpretted in (say) a Dim statement? What about rules governing
whether a collection is returned in evaluating an expression, or
whether a default object within the collection is returned?

Thanks. (I'm using Office 2003)



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Range object evaluates to Range.value, or Range object

objects are assigned using the SET command.

for the range object, the value property is the default

so
dim x as string
x = range("A1")
is the same as
x = range("A1").Value
which is the "correct" coding - no ambiguity/guesses, it reads more clearly,
and with .NET, mandatory

but now
dim x as range
SET x = Range("A1")
creates an object referencing the sheet range. what you do to that, you see
on the sheet

with x
..Value = 12
..Interior.ColorIndex = 4
end with

read help on the excel object model will cover a good deal of this




wrote in message
...
In most equations, when a Range object shows up in an expression on
the right hand side of the assignment operator "=", the range object's
value is used. I'm interested in assigning a range object to a
variable that has been dim'd as type Range.

Where can one find the rules that govern what objects evaluate to when
they show up in expressions?

Also, in many cases, things like Range are used in the documentation
to describe a Range object as well as a collection of range objects.
Where in the documentation does it describe how the word Range is
interpretted in (say) a Dim statement? What about rules governing
whether a collection is returned in evaluating an expression, or
whether a default object within the collection is returned?

Thanks. (I'm using Office 2003)

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Range object evaluates to Range.value, or Range object

objects are assigned using the SET command.

for the range object, the value property is the default

so
dim x as string
x = range("A1")
is the same as
x = range("A1").Value
which is the "correct" coding - no ambiguity/guesses, it reads more clearly,
and with .NET, mandatory

but now
dim x as range
SET x = Range("A1")
creates an object referencing the sheet range. what you do to that, you see
on the sheet

with x
..Value = 12
..Interior.ColorIndex = 4
end with

read help on the excel object model will cover a good deal of this




wrote in message
...
In most equations, when a Range object shows up in an expression on
the right hand side of the assignment operator "=", the range object's
value is used. I'm interested in assigning a range object to a
variable that has been dim'd as type Range.

Where can one find the rules that govern what objects evaluate to when
they show up in expressions?

Also, in many cases, things like Range are used in the documentation
to describe a Range object as well as a collection of range objects.
Where in the documentation does it describe how the word Range is
interpretted in (say) a Dim statement? What about rules governing
whether a collection is returned in evaluating an expression, or
whether a default object within the collection is returned?

Thanks. (I'm using Office 2003)



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Range object evaluates to Range.value, or Range object

Patrick,

Thanks for that. I found that the object model leads me to navigate
the class definitions, but haven't found my way to description of the
semantics of that aspect of the language (though I'm sure it's there).

On Jun 3, 2:14*pm, "Patrick Molloy"
wrote:
objects are assigned using the SET command.

for the range object, the value property is the default

so
dim x as string
x = range("A1")
is the same as
x = range("A1").Value
which is the "correct" coding - no ambiguity/guesses, it reads more clearly,
and with .NET, mandatory

but now
dim x as range
SET x = Range("A1")
creates an object referencing the sheet range. what you do to that, you see
on the sheet

with x
.Value = 12
.Interior.ColorIndex = 4
end with

read help on the excel object model will cover a good deal of this

wrote in message

...



In most equations, when a Range object shows up in an expression on
the right hand side of the assignment operator "=", the range object's
value is used. *I'm interested in assigning a range object to a
variable that has been dim'd as type Range.


Where can one find the rules that govern what objects evaluate to when
they show up in expressions?


Also, in many cases, things like Range are used in the documentation
to describe a Range object as well as a collection of range objects.
Where in the documentation does it describe how the word Range is
interpretted in (say) a Dim statement? *What about rules governing
whether a collection is returned in evaluating an expression, or
whether a default object within the collection is returned?


Thanks. *(I'm using Office 2003)- Hide quoted text -


- Show quoted text -


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Range object evaluates to Range.value, or Range object

Patrick,

Thanks for that. I found that the object model leads me to navigate
the class definitions, but haven't found my way to description of the
semantics of that aspect of the language (though I'm sure it's there).

On Jun 3, 2:14*pm, "Patrick Molloy"
wrote:
objects are assigned using the SET command.

for the range object, the value property is the default

so
dim x as string
x = range("A1")
is the same as
x = range("A1").Value
which is the "correct" coding - no ambiguity/guesses, it reads more clearly,
and with .NET, mandatory

but now
dim x as range
SET x = Range("A1")
creates an object referencing the sheet range. what you do to that, you see
on the sheet

with x
.Value = 12
.Interior.ColorIndex = 4
end with

read help on the excel object model will cover a good deal of this

wrote in message

...



In most equations, when a Range object shows up in an expression on
the right hand side of the assignment operator "=", the range object's
value is used. *I'm interested in assigning a range object to a
variable that has been dim'd as type Range.


Where can one find the rules that govern what objects evaluate to when
they show up in expressions?


Also, in many cases, things like Range are used in the documentation
to describe a Range object as well as a collection of range objects.
Where in the documentation does it describe how the word Range is
interpretted in (say) a Dim statement? *What about rules governing
whether a collection is returned in evaluating an expression, or
whether a default object within the collection is returned?


Thanks. *(I'm using Office 2003)- Hide quoted text -


- Show quoted text -


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Range object evaluates to Range.value, or Range object

Thanks for that, Bernie.

On Jun 3, 2:07*pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Paul,

You need to use Set:

Dim objRange As Range
Set objRange = Range("A1")
Msgbox objRange.Address & " is " & objRange.Value

HTH,
Bernie
MS Excel MVP

wrote in message

...



In most equations, when a Range object shows up in an expression on
the right hand side of the assignment operator "=", the range object's
value is used. *I'm interested in assigning a range object to a
variable that has been dim'd as type Range.


Where can one find the rules that govern what objects evaluate to when
they show up in expressions?


Also, in many cases, things like Range are used in the documentation
to describe a Range object as well as a collection of range objects.
Where in the documentation does it describe how the word Range is
interpretted in (say) a Dim statement? *What about rules governing
whether a collection is returned in evaluating an expression, or
whether a default object within the collection is returned?


Thanks. *(I'm using Office 2003)

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Range object evaluates to Range.value, or Range object

Thanks for that, Bernie.

On Jun 3, 2:07*pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Paul,

You need to use Set:

Dim objRange As Range
Set objRange = Range("A1")
Msgbox objRange.Address & " is " & objRange.Value

HTH,
Bernie
MS Excel MVP

wrote in message

...



In most equations, when a Range object shows up in an expression on
the right hand side of the assignment operator "=", the range object's
value is used. *I'm interested in assigning a range object to a
variable that has been dim'd as type Range.


Where can one find the rules that govern what objects evaluate to when
they show up in expressions?


Also, in many cases, things like Range are used in the documentation
to describe a Range object as well as a collection of range objects.
Where in the documentation does it describe how the word Range is
interpretted in (say) a Dim statement? *What about rules governing
whether a collection is returned in evaluating an expression, or
whether a default object within the collection is returned?


Thanks. *(I'm using Office 2003)

  #10   Report Post  
Posted to microsoft.public.excel.programming
r r is offline
external usenet poster
 
Posts: 125
Default Range object evaluates to Range.value, or Range object

Sub test()
Dim rng As Excel.Range
Debug.Print TypeName(rng) 'Nothing
Debug.Print VarType(rng) '9 - vbObject

Set rng = [a1]

Debug.Print TypeName(rng) 'Range
Debug.Print TypeName(rng.Value) 'Empty
Debug.Print VarType(rng) '0 - vbEmpty
Debug.Print VarType(rng.Value) '0 - vbEmpty

rng.Value = 1

Debug.Print TypeName(rng) 'Range
Debug.Print TypeName(rng.Value) 'Double
Debug.Print VarType(rng) '5 - vbDouble
Debug.Print VarType(rng.Value) '5 - vbDouble

End Sub

regards
r

Il mio ultimo lavoro ...
http://excelvba.altervista.org/blog/...ternative.html


" wrote:

In most equations, when a Range object shows up in an expression on
the right hand side of the assignment operator "=", the range object's
value is used. I'm interested in assigning a range object to a
variable that has been dim'd as type Range.

Where can one find the rules that govern what objects evaluate to when
they show up in expressions?

Also, in many cases, things like Range are used in the documentation
to describe a Range object as well as a collection of range objects.
Where in the documentation does it describe how the word Range is
interpretted in (say) a Dim statement? What about rules governing
whether a collection is returned in evaluating an expression, or
whether a default object within the collection is returned?

Thanks. (I'm using Office 2003)




  #11   Report Post  
Posted to microsoft.public.excel.programming
r r is offline
external usenet poster
 
Posts: 125
Default Range object evaluates to Range.value, or Range object

Sub test()
Dim rng As Excel.Range
Debug.Print TypeName(rng) 'Nothing
Debug.Print VarType(rng) '9 - vbObject

Set rng = [a1]

Debug.Print TypeName(rng) 'Range
Debug.Print TypeName(rng.Value) 'Empty
Debug.Print VarType(rng) '0 - vbEmpty
Debug.Print VarType(rng.Value) '0 - vbEmpty

rng.Value = 1

Debug.Print TypeName(rng) 'Range
Debug.Print TypeName(rng.Value) 'Double
Debug.Print VarType(rng) '5 - vbDouble
Debug.Print VarType(rng.Value) '5 - vbDouble

End Sub

regards
r

Il mio ultimo lavoro ...
http://excelvba.altervista.org/blog/...ternative.html


" wrote:

In most equations, when a Range object shows up in an expression on
the right hand side of the assignment operator "=", the range object's
value is used. I'm interested in assigning a range object to a
variable that has been dim'd as type Range.

Where can one find the rules that govern what objects evaluate to when
they show up in expressions?

Also, in many cases, things like Range are used in the documentation
to describe a Range object as well as a collection of range objects.
Where in the documentation does it describe how the word Range is
interpretted in (say) a Dim statement? What about rules governing
whether a collection is returned in evaluating an expression, or
whether a default object within the collection is returned?

Thanks. (I'm using Office 2003)


  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Range object evaluates to Range.value, or Range object

Thanks, r.

That is an extremely illuminating and simple example that illustrates
all the subleties that could leave a newbie scratching one's head.

On Jun 3, 7:04*pm, r wrote:
Sub test()
Dim rng As Excel.Range
Debug.Print TypeName(rng) 'Nothing
Debug.Print VarType(rng) '9 - vbObject

Set rng = [a1]

Debug.Print TypeName(rng) 'Range
Debug.Print TypeName(rng.Value) 'Empty
Debug.Print VarType(rng) '0 - vbEmpty
Debug.Print VarType(rng.Value) '0 - vbEmpty

rng.Value = 1

Debug.Print TypeName(rng) 'Range
Debug.Print TypeName(rng.Value) 'Double
Debug.Print VarType(rng) '5 - vbDouble
Debug.Print VarType(rng.Value) '5 - vbDouble

End Sub

regards
r

Il mio ultimo lavoro ...http://excelvba.altervista.org/blog/.../UsedRange-ecc...



" wrote:
In most equations, when a Range object shows up in an expression on
the right hand side of the assignment operator "=", the range object's
value is used. *I'm interested in assigning a range object to a
variable that has been dim'd as type Range.


Where can one find the rules that govern what objects evaluate to when
they show up in expressions?


Also, in many cases, things like Range are used in the documentation
to describe a Range object as well as a collection of range objects.
Where in the documentation does it describe how the word Range is
interpretted in (say) a Dim statement? *What about rules governing
whether a collection is returned in evaluating an expression, or
whether a default object within the collection is returned?


Thanks. *(I'm using Office 2003)- Hide quoted text -


- Show quoted text -


  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Range object evaluates to Range.value, or Range object

Thanks, r.

That is an extremely illuminating and simple example that illustrates
all the subleties that could leave a newbie scratching one's head.

On Jun 3, 7:04*pm, r wrote:
Sub test()
Dim rng As Excel.Range
Debug.Print TypeName(rng) 'Nothing
Debug.Print VarType(rng) '9 - vbObject

Set rng = [a1]

Debug.Print TypeName(rng) 'Range
Debug.Print TypeName(rng.Value) 'Empty
Debug.Print VarType(rng) '0 - vbEmpty
Debug.Print VarType(rng.Value) '0 - vbEmpty

rng.Value = 1

Debug.Print TypeName(rng) 'Range
Debug.Print TypeName(rng.Value) 'Double
Debug.Print VarType(rng) '5 - vbDouble
Debug.Print VarType(rng.Value) '5 - vbDouble

End Sub

regards
r

Il mio ultimo lavoro ...http://excelvba.altervista.org/blog/.../UsedRange-ecc...



" wrote:
In most equations, when a Range object shows up in an expression on
the right hand side of the assignment operator "=", the range object's
value is used. *I'm interested in assigning a range object to a
variable that has been dim'd as type Range.


Where can one find the rules that govern what objects evaluate to when
they show up in expressions?


Also, in many cases, things like Range are used in the documentation
to describe a Range object as well as a collection of range objects.
Where in the documentation does it describe how the word Range is
interpretted in (say) a Dim statement? *What about rules governing
whether a collection is returned in evaluating an expression, or
whether a default object within the collection is returned?


Thanks. *(I'm using Office 2003)- Hide quoted text -


- Show quoted text -


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
drop first row in range and return a new range object Rik Excel Programming 1 November 19th 08 10:12 AM
Select a PivotField range without using the range object Mike Excel Programming 1 February 26th 08 09:23 PM
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
Range Question / error 1004: method Range of object Worksheet has failed Paul Excel Programming 3 April 7th 05 02:56 PM
using RANGE object in multiple-area range TerryT Excel Programming 3 December 8th 04 09:13 PM


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