View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
srroduin srroduin is offline
external usenet poster
 
Posts: 34
Default Insert rows in the middle of the document???

Thanks Tom for your help....

It's getting closer....

The dates I'm working with don't match. The dates on sheet1 will fit into
the dates on sheet2.

sheet2 looks like this
col n col o
Jan2, 2006 april 16, 2006
April 16, 2006 May 3, 2006
May 3, 2006 dec 31, 2006


sheet1 looks like this
col a (start) col c
feb 14, 2006 feb 20, 2006

I have to make it look like this on sheet2
col n col o
Jan2, 2006 feb 14, 2006
feb 14, 2006 feb 20, 2006
feb 20, 2006 april 16, 2006
april 16, 2006 may 3, 2006
may 3, 2006 dec 31, 2006

any ideas???


"Tom Ogilvy" wrote:

Assuming each date on sheet2 is unique and is located in column A
Insert n rows:

Dim rng as Range, rng1 as Range
Dim rng2 as Range, n as Long
Dim res as Variant
n = 3
with worksheets("Sheet2")
set rng2 = .Range(.Cells(1,1),.Cells(1,1).End(xldown))
End With
set rng1 = Worksheets("Sheet1").Range("A1")
res = application.Match(rng1,rng2,0)
if not iserror(res) then
set rng = rng2(res)
rng.offset(1,0).Resize(n,1).EntireRow.Insert
end if

would be an approach.

--
Regards,
Tom Ogilvy


"srroduin" wrote in message
...
Given an initial date on worksheet 1 and
Given lots of data on worksheet 2 with dates start and finish

How do I insert a variable # of blank rows in worksheet 2 under where the
initial date falls in between?

start date < initial date < finish date

Thanks to Ron I've been able to select, copy and paste my stuff from
worksheet 1 to 2......but I've only been successful adding them at the

bottom
of the page. I need to be able to fit it between the right time periods.

Thanks in Advance!