LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default How do I programmatically specify a range.

Hi,

In column D and row number p , where p = Range("b65536").End(xlUp).Row, I
have a ARRAYFORMULA.

Presently the VBA control is in the above specified cell.

I want to copy this formula in to all cells in the column D starting from
row 2 to row p-1.

So, I wrote the following code, (using macro recorder)

If ActiveCell.Address < D2 Then
Selection.Copy
ActiveCell.Offset(-1, 0).Range("A1").Select
Range(Selection, Selection.End(xlUp)).Select
ActiveCell.Offset(-6, 0).Range("A1:A7").Select
ActiveCell.Activate
ActiveSheet.Paste

Problem is the in the above case p, the row number was equal to 9, hence
while recording I got the pasting only in D2:D8. How do I make the range
reference dynamic.

I tried with the relative referencing off but again this is also useless to
me.

Selection.Copy
Range("D8").Select
Range(Selection, Selection.End(xlUp)).Select
Range("D2:D8").Select
Range("D8").Activate
ActiveSheet.Paste

Please tell me the correct syntax wherby I could copy the formula in column
D, row P to all the cells above row P except cell D1.

--
Thanks a lot,
Hari
India


 
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
trying to programmatically change chart data range with vb.net doofy[_2_] Charts and Charting in Excel 7 February 8th 08 02:02 PM
delete row programmatically Pat Excel Programming 2 September 2nd 04 09:11 PM
Is it possible to change the Input Range of a Form Control programmatically? dchow Excel Programming 3 November 21st 03 02:10 PM
How to Programmatically Insert a Page Break Every Nth Row in a Range KK[_3_] Excel Programming 0 November 21st 03 12:49 AM
Summing a variable sized range programmatically Norma[_2_] Excel Programming 3 August 24th 03 07:31 PM


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