Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default How does .offset(i, counter) work?

Hi everypne,

How does the following piece of code work:

With Range("G2")
For i = 1 To 30
.Offset(i, ModelCounter) = Range("Picked").Cells(i)
Next
End With

In particular the offset line please!

Thanks,
Mike

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,090
Default How does .offset(i, counter) work?

Mike
The With/End With construct says that cell G2 is the reference cell.
The ".Offset(i, ModelCounter)" says "the cell that is "i" rows down and
"ModelCounter" columns to the right (if ModelCounter is positive) from G2.
HTH Otto
"Mike" wrote in message
oups.com...
Hi everypne,

How does the following piece of code work:

With Range("G2")
For i = 1 To 30
.Offset(i, ModelCounter) = Range("Picked").Cells(i)
Next
End With

In particular the offset line please!

Thanks,
Mike



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How does .offset(i, counter) work?


With Range("G2")
For i = 1 To 30
.Offset(i, ModelCounter) = Range("Picked").Cells(i)
Next
End With


The above script enters data into cell G2 + i rows + ModelCounte
columns

And gets data from the range "Picked", cell number i.

So basically, it goes down the 30 rows according to i, taking the i't
cell from "Picked" and puts it in G2 + ModelCounter columns and
rows.

So if ModelCounter is 4, it will start in K3, K4, K5 .....

--
dspence
-----------------------------------------------------------------------
dspencer's Profile: http://www.excelforum.com/member.php...fo&userid=3096
View this thread: http://www.excelforum.com/showthread.php?threadid=50636

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default How does .offset(i, counter) work?

Dspencer,

As a follows up on the last line of your reply, say I want it to start
in K2 instead of K3,

What change should I make?

Thanks alot in advance,
Mike

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default How does .offset(i, counter) work?

With range("G1")

would do.

"Mike" wrote:

Dspencer,

As a follows up on the last line of your reply, say I want it to start
in K2 instead of K3,

What change should I make?

Thanks alot in advance,
Mike


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
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Worksheet Functions 2 September 28th 07 10:54 PM
activecell.offset does not work hans[_3_] Excel Programming 7 November 21st 04 06:53 AM
Trouble getting the OFFSET fo work JimP Excel Programming 7 July 29th 04 01:49 PM
Counter JonoB[_4_] Excel Programming 4 May 6th 04 12:19 PM
Counter Larry Hau Excel Programming 1 August 14th 03 11:00 PM


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