Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Saving Range Locatoin into a Variable

Hi Dale,

Since you declare oSave_Del_Rng as a Range object (and set it using Set ...
= ...), the object variable contains a reference to the Range object you set
it to [in this case, oSave_Del_Rng is the same as typing Range("Q215")].
Since the default property of a Range object is Value, you will get the
value of the range Q215 when you refer to your variable. To get the
address, you can use the Address property:

Debug.Print oSave_Del_Rng.Address

Regards,

Jake Marx
MS MVP - Excel


"Dale Cox" wrote in message
...
The following code executes just fine. The value moved
into oSave_Del_Rng, however, is the value in the Cell
Q215. I need the cell address, not the value of the cell,
moved into the variable.
Const sDelivery_Rng = "Q215"
Dim oSave_Del_Rng as Range
Set oSave_Del_Rng = Range(sDelivery_Rng)

Help!



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Saving Range Locatoin into a Variable

Hi Bob,

"Bob Phillips" wrote in message
...
Jake,

You're back! Where have you been? I guess you must have a life<vbg.


Yeah, life has been taking up a lot of my time lately. <g A new baby and
job are the biggest time consumers right now. But they're definitely worth
it...at least the baby is. Hopefully, I'll be able to start spending some
more time here in the upcoming months.

Thanks,

Jake Marx
MS MVP - Excel


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Saving Range Locatoin into a Variable

Sorry, but I'm relatively new to VBA. I tried the
following
Set oSave_Del_Rng.Address = Range(sDelivery_Rng)
which would not fly.

-----Original Message-----
Hi Dale,

Since you declare oSave_Del_Rng as a Range object (and

set it using Set ...
= ...), the object variable contains a reference to the

Range object you set
it to [in this case, oSave_Del_Rng is the same as typing

Range("Q215")].
Since the default property of a Range object is Value,

you will get the
value of the range Q215 when you refer to your

variable. To get the
address, you can use the Address property:

Debug.Print oSave_Del_Rng.Address

Regards,

Jake Marx
MS MVP - Excel


"Dale Cox" wrote in message
...
The following code executes just fine. The value moved
into oSave_Del_Rng, however, is the value in the Cell
Q215. I need the cell address, not the value of the

cell,
moved into the variable.
Const sDelivery_Rng = "Q215"
Dim oSave_Del_Rng as Range
Set oSave_Del_Rng = Range(sDelivery_Rng)

Help!



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Saving Range Locatoin into a Variable

Hi Dale,

Sorry, but I'm relatively new to VBA. I tried the
following
Set oSave_Del_Rng.Address = Range(sDelivery_Rng)
which would not fly.


Your code was OK as is, it was just that the variable was not what you
thought it was. Since you declared it as Range, it was actually a range
object. So by using this at the end of your original code:

MsgBox oSave_Del_Rng.Address

the range address would be displayed in a messagebox.

Bob's code is more straightforward if you only want the Address property and
don't need any other properties of the Range you're referring to (Value, Row
#, Column #, etc). If that's the case, you can do it in a one-liner:

MsgBox Range(sDelivery_Rng).Address

Hopefully that clears things up a bit.

Regards,

Jake Marx
MS MVP - Excel


-----Original Message-----
Hi Dale,

Since you declare oSave_Del_Rng as a Range object (and

set it using Set ...
= ...), the object variable contains a reference to the

Range object you set
it to [in this case, oSave_Del_Rng is the same as typing

Range("Q215")].
Since the default property of a Range object is Value,

you will get the
value of the range Q215 when you refer to your

variable. To get the
address, you can use the Address property:

Debug.Print oSave_Del_Rng.Address

Regards,

Jake Marx
MS MVP - Excel


"Dale Cox" wrote in message
...
The following code executes just fine. The value moved
into oSave_Del_Rng, however, is the value in the Cell
Q215. I need the cell address, not the value of the

cell,
moved into the variable.
Const sDelivery_Rng = "Q215"
Dim oSave_Del_Rng as Range
Set oSave_Del_Rng = Range(sDelivery_Rng)

Help!



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Saving Range Locatoin into a Variable

Well that's a good reason, and congrats.

I hope we will be seeing more of you, I've always felt you add to the group.

All the best

Bob

"Jake Marx" wrote in message
...
Hi Bob,

"Bob Phillips" wrote in message
...
Jake,

You're back! Where have you been? I guess you must have a life<vbg.


Yeah, life has been taking up a lot of my time lately. <g A new baby and
job are the biggest time consumers right now. But they're definitely

worth
it...at least the baby is. Hopefully, I'll be able to start spending some
more time here in the upcoming months.

Thanks,

Jake Marx
MS MVP - Excel




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
Saving as variable file name leerem Excel Discussion (Misc queries) 1 September 29th 08 10:30 AM
variable range John New Users to Excel 2 July 21st 06 03:42 PM
Variable range in VB famdamly Excel Discussion (Misc queries) 2 January 22nd 06 02:29 PM
Variable in Range aftamath Excel Discussion (Misc queries) 2 October 6th 05 07:48 PM
Saving Registry variable to ini file Allen[_3_] Excel Programming 0 September 10th 03 06:14 PM


All times are GMT +1. The time now is 04:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"