Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default VBA: copying and inserting a dynamic range

Hi,

I am trying to copy a dynamic range ("Sheet1!A2:F(unknown)") and
insert the copied content in cell "Sheet2!A2" on top of already
existing data. I have tried some approaches but haven't been able to
accomplish this. Recording a macro requires known ranges, I would
like to accomplish this for variable ranges.

The final approach that I came up with is as follows:
Range(Sheet1!A2, Sheet1!F65536.End(xlUp)).Value.Copy
Range(Sheet2!A2).Insert shift:=xlDown

Unfortunately, this doesn't work, and I get the error "object is
required".
Does anyone know of a concise solution to this in vba?

Thanks

JP

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default copying and inserting a dynamic range_Attn: William

William,

Thanks so much for the reply. The code worked alright except for a
minor snag (inserting an extra blank line, which I managed to work
around it).

Have a great summer

JP


On Tue, 1 Jun 2004 03:55:43 +0100, "William"
wrote:

Hi JP

Sub test()
Dim r As Range, i As Long
With Sheets("Sheet1")
Set r = .Range(.Range("A2"), _
.Range("A" & Rows.Count).End(xlUp).Offset(0, 5))
i = r.Rows.Count
End With
With Sheets("Sheet2")
.Range("A2:F" & i).Insert Shift:=xlDown
.Range("A2:F" & i).Formula = r.Value2
End With
End Sub


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
Copying and inserting lines teo410 Excel Worksheet Functions 6 August 13th 09 05:31 PM
Copying row & inserting Chance224 Excel Discussion (Misc queries) 1 September 2nd 06 03:03 AM
Help with copying dynamic column selected based on remote cell value and dynamic formula fill ers Charts and Charting in Excel 0 March 1st 06 01:05 AM
Dynamic Range with unused formula messing up x axis on dynamic graph [email protected] Charts and Charting in Excel 2 February 2nd 06 08:02 PM
Inserting Lines And Copying Them Troyk Excel Programming 1 May 27th 04 03:19 PM


All times are GMT +1. The time now is 05:03 AM.

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"