View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy[_2_] Patrick Molloy[_2_] is offline
external usenet poster
 
Posts: 1,298
Default macro adding rows

so with my code you changed the column to 4 and/or with Per's you changed the
target column to D ?
what was the mismatch relating to?

"dobbers" wrote:

Hi,

The dates are in columns D and E i have other information before them such
as names vehicle registrations and a project code

Thanks,

james

"Patrick Molloy" wrote:

we both assumed your line was two dates with times in two separate columns.
I stated that was my presumption.
isn't that the case? What are the details of the mismatch?



"dobbers" wrote:

Hi,

Tried both of the options and bothe returned a mismatch error

Thanks,

James

"Per Jessen" wrote:

Hi

Try this:

Sub InsertRow()
TargetCol = "A"
Firstrow = 2 'Headings in row 1
LastRow = Cells(Rows.Count, TargetCol).End(xlUp).Row

For r = LastRow - 1 To Firstrow Step -1
If Cells(r, TargetCol).Value < Cells(r + 1, TargetCol) Then
Rows(r + 1).Insert
End If
Next
End Sub

Regards,
Per

"dobbers" skrev i meddelelsen
...
hi,

I have a worksheet that contains data formatted with name start date and
time and finish date and time. I am looking for a macro to insert a row
after
each date for example

21/09/2009 13:54 21/09/2009 14:05
21/09/2009 16:59 21/09/2009 18:11

22/09/2009 06:57 22/09/2009 07:15
22/09/2009 07:59 22/09/2009 08:15
22/09/2009 09:29 22/09/2009 09:35
22/09/2009 10:52 22/09/2009 11:14
22/09/2009 12:35 22/09/2009 13:02
22/09/2009 15:04 22/09/2009 15:15
22/09/2009 16:49 22/09/2009 17:18

23/09/2009 06:58 23/09/2009 07:14
23/09/2009 07:51 23/09/2009 08:20
23/09/2009 09:00 23/09/2009 09:18
23/09/2009 12:07 23/09/2009 12:13
23/09/2009 12:40 23/09/2009 12:52
23/09/2009 16:29 23/09/2009 16:50
23/09/2009 17:07 23/09/2009 17:25

As you can see there could be multiple start times for any day any help or
advice then please let me know as it is taking far to long to do manually

Thanks,

James