Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Offset with variable?

I get an error on this simple line of code...

st1 = st1.Offset(1, 0)

st1 is a range... is there anyother way to make st1 step one cell down?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Offset with variable?

Hi John,

Try:

Set st1 = st1.Offset(1,0)


---
Regards,
Norman



"John" wrote in message
...
I get an error on this simple line of code...

st1 = st1.Offset(1, 0)

st1 is a range... is there anyother way to make st1 step one cell down?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Offset with variable?

Hi John,

John wrote:
I get an error on this simple line of code...

st1 = st1.Offset(1, 0)

st1 is a range... is there anyother way to make st1 step one cell
down?


Since st1 is a Range object, you need to use the Set command if you want to
change its reference. Otherwise, VBA is going to assign the Value of the
cell below st1 to the cell referred to by st1. You shouldn't get an error,
though - that line of code executes for me, it just yields unexpected
results.

Dim st1 As Range

Set st1 = Range("A1")
Set st1 = st1.Offset(1,0) '/ now st1 refers to B1

--
Regards,

Jake Marx
www.longhead.com


[please keep replies in the newsgroup - email address unmonitored]


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Offset with variable?

thanks :)

"Norman Jones" wrote:

Hi John,

Try:

Set st1 = st1.Offset(1,0)


---
Regards,
Norman



"John" wrote in message
...
I get an error on this simple line of code...

st1 = st1.Offset(1, 0)

st1 is a range... is there anyother way to make st1 step one cell down?




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
VLookup Variable Offset Glenda Excel Discussion (Misc queries) 1 April 7th 10 02:01 PM
Variable worksheet name in offset Dave T Excel Worksheet Functions 2 January 25th 07 07:41 PM
Using Offset on Variable Dinensioneds Object ExcelMonkey Excel Programming 3 August 19th 05 05:44 PM
Offset with variable James Excel Programming 2 August 16th 05 08:27 PM
How to Offset string variable? Alan Ibbotson Excel Programming 2 May 9th 04 09:22 PM


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