Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default named range/offset

Hello,
I was playing around with the offset. Wanted to get users opinions of
offset.

If I have a named range. and I want to get the row above, below, etc...
Do people like using offset?

It seems like I can do,

Range("myRange").Offset(-1)
and it will give me the range = same column and 1 row above.

is this bad to do?
thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default named range/offset

In my opinion there is no problem at all with using Offset. You do need to
make a correct to your code below.

Dim myRange as Range

Set myRange = Range("A1:B2") 'or some other range

Range("myRange").Offset(-1)

Hope this helped!
--
Cheers,
Ryan


"greg" wrote:

Hello,
I was playing around with the offset. Wanted to get users opinions of
offset.

If I have a named range. and I want to get the row above, below, etc...
Do people like using offset?

It seems like I can do,

Range("myRange").Offset(-1)
and it will give me the range = same column and 1 row above.

is this bad to do?
thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default named range/offset

Have you tried that code??? It does not look like it will work to me...

Dim myRange as Range 'declare a range object

Set myRange = Range("A1:B2") 'define the range object
Range("myRange").Offset(-1) 'myRange is now text

When you put myRange in quotes it is now looking for a Named Range (which is
what Greg originally had which is just fine). But that has nothing to do with
your range object. Assuming you remove the quotes then the range object is
used but the default property of a range object is it's value and not it's
address so you still get the wrong result. Finally Assuming that you had

myRange.offset(-1)

which would correctly use your range object you would get a subscrpit out of
range error as you are trying to offset right off of the sheet.


All of this ignores that
Range("myRange").Offset(-1)
results in specifying a range which is not used...

--
HTH...

Jim Thomlinson


"RyanH" wrote:

In my opinion there is no problem at all with using Offset. You do need to
make a correct to your code below.

Dim myRange as Range

Set myRange = Range("A1:B2") 'or some other range

Range("myRange").Offset(-1)

Hope this helped!
--
Cheers,
Ryan


"greg" wrote:

Hello,
I was playing around with the offset. Wanted to get users opinions of
offset.

If I have a named range. and I want to get the row above, below, etc...
Do people like using offset?

It seems like I can do,

Range("myRange").Offset(-1)
and it will give me the range = same column and 1 row above.

is this bad to do?
thanks



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 192
Default named range/offset

Hey Greg,

Personally, I love offset. It is especially useful (for what I've done) in
loops with copying/pasting so I'll have:

curselection.Copy Range("A7").Offset(i +1, 0)

where i is the loop number. Some people may not like it, but I have found
it very useful.

Just my two cents...

"greg" wrote:

Hello,
I was playing around with the offset. Wanted to get users opinions of
offset.

If I have a named range. and I want to get the row above, below, etc...
Do people like using offset?

It seems like I can do,

Range("myRange").Offset(-1)
and it will give me the range = same column and 1 row above.

is this bad to do?
thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default named range/offset

When I was a beginner, any code that worked was good code, as far as I was
concerned. Today, any code that works is good code, as far as I am
concerned. There is always somebody who can make it look better, run faster
or some other frill. Unless you are writing code commercially, including the
company you work for, frills are just that. When you learn more, get more
confidence in your abilities and have a data base of references for code
structure, storage space conservation, execution speeds and so on, you might
want to be more concerned about applying those things. In the mean time,
when it works, rejoice.

"greg" wrote:

Hello,
I was playing around with the offset. Wanted to get users opinions of
offset.

If I have a named range. and I want to get the row above, below, etc...
Do people like using offset?

It seems like I can do,

Range("myRange").Offset(-1)
and it will give me the range = same column and 1 row above.

is this bad to do?
thanks





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default named range/offset

What other choices do you have?

maybe

Range("myRange").Cells(0,1)

but that is horrible.

--
__________________________________
HTH

Bob

"greg" wrote in message
...
Hello,
I was playing around with the offset. Wanted to get users opinions of
offset.

If I have a named range. and I want to get the row above, below, etc...
Do people like using offset?

It seems like I can do,

Range("myRange").Offset(-1)
and it will give me the range = same column and 1 row above.

is this bad to do?
thanks



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default named range/offset

On Tue, 24 Jun 2008 16:44:39 -0500, "greg" wrote:

I use the offset funtion frequently in combination with CurrentCell

Set CurrentCell = Worksheets("Whatever").Range("$B$4") 'or named range
Do Until IsEmpty(CurrentCell)
Set CurrentCell = CurrentCell.Offset(1, 0)
Loop

I like it because it doesn't really select the cell. This probably
isn't a good example but it does what I need it to do.

Hello,
I was playing around with the offset. Wanted to get users opinions of
offset.

If I have a named range. and I want to get the row above, below, etc...
Do people like using offset?

It seems like I can do,

Range("myRange").Offset(-1)
and it will give me the range = same column and 1 row above.

is this bad to do?
thanks

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default named range/offset

thanks all for the help


"greg" wrote in message
...
Hello,
I was playing around with the offset. Wanted to get users opinions of
offset.

If I have a named range. and I want to get the row above, below, etc...
Do people like using offset?

It seems like I can do,

Range("myRange").Offset(-1)
and it will give me the range = same column and 1 row above.

is this bad to do?
thanks



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
Named range is hidden when using OFFSET() Conan Kelly Excel Discussion (Misc queries) 1 October 8th 07 08:56 PM
Find and offset in named Range [email protected] Excel Programming 9 August 30th 06 07:44 PM
named range row offset [email protected] Excel Worksheet Functions 5 July 8th 06 01:35 AM
how to use offset with non-adjacent named range Tig[_2_] Excel Programming 4 April 14th 05 02:35 AM
named range / offset Gixxer_J_97[_2_] Excel Programming 5 March 11th 05 09:09 PM


All times are GMT +1. The time now is 01:03 PM.

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"