Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 19
Default Macro offset using the value in a cell

Hello,

I am looking to Copy a cell then paste n rows lower. I would like this
number n to be a value in a cell. i.e. If cell A1 = 2, then copy B1 two rows
lower (i.e. to B3). If cell A1=4, then copy B1 four rows lower (i.e. to B5).

I know offset ( , ) should be used for this, but as a novice I don't seem to
be able to put the cell reference in i.e. offset (A1,0)

Any help would be appreciated!
thanks
Stephen, London
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Macro offset using the value in a cell

Hi,

try this

Range("A1").Offset(Range("A1").Value - 1, 1).Value = Range("A1").Value

so if A1 contains a 4, that value is copied to B4

Mike

"StephenT" wrote:

Hello,

I am looking to Copy a cell then paste n rows lower. I would like this
number n to be a value in a cell. i.e. If cell A1 = 2, then copy B1 two rows
lower (i.e. to B3). If cell A1=4, then copy B1 four rows lower (i.e. to B5).

I know offset ( , ) should be used for this, but as a novice I don't seem to
be able to put the cell reference in i.e. offset (A1,0)

Any help would be appreciated!
thanks
Stephen, London

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Macro offset using the value in a cell

with activesheet
.range("B1").copy _
destination:=.range("b1").offset(.range("a1").valu e,0)
end with

There are no validity checks here. If you have a number too small (negative) or
too large or even text in A1, then it'll blow up.

StephenT wrote:

Hello,

I am looking to Copy a cell then paste n rows lower. I would like this
number n to be a value in a cell. i.e. If cell A1 = 2, then copy B1 two rows
lower (i.e. to B3). If cell A1=4, then copy B1 four rows lower (i.e. to B5).

I know offset ( , ) should be used for this, but as a novice I don't seem to
be able to put the cell reference in i.e. offset (A1,0)

Any help would be appreciated!
thanks
Stephen, London


--

Dave Peterson
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
Delete Macro using Offset Alex.W Excel Discussion (Misc queries) 3 April 9th 08 11:37 PM
macro offset cell value and sum simplymidori[_2_] Excel Discussion (Misc queries) 0 December 27th 07 11:09 AM
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Worksheet Functions 2 September 28th 07 10:54 PM
offset macro based on multiple criteria davemon Excel Discussion (Misc queries) 1 September 21st 07 03:15 PM
macro to search and replace with offset Tim Excel Discussion (Misc queries) 5 December 11th 04 09:30 PM


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