Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Conditional Copy Macro

Hello:

I have a column of data that is a list of dates and times as a schedule.
Each date listed may have several times underneath it (i.e., 4/16/08 could
have 9:00AM, 10AM, 11AM underneath it). I would like to be able to
automatically erase the times and replace them with the date they fall under.
Each date may have anywhere from 0-5 times listed underneath them, but each
date is ALWAYS separated by one blank cell. Is there anyway to do this via a
macro?

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Conditional Copy Macro

You said "I would like to be able to automatically erase the times and
replace them with the date..."; is this really what you want? Won't that
result in the same date listed 1 to 5 times with no time values show at all?

Rick


I have a column of data that is a list of dates and times as a schedule.
Each date listed may have several times underneath it (i.e., 4/16/08 could
have 9:00AM, 10AM, 11AM underneath it). I would like to be able to
automatically erase the times and replace them with the date they fall
under.
Each date may have anywhere from 0-5 times listed underneath them, but
each
date is ALWAYS separated by one blank cell. Is there anyway to do this via
a
macro?

Thanks.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Conditional Copy Macro

Change StartRow and MyColumn as required.

Sub change_time()

MyColumn = "A"
StartRow = 1

LastRow = Range(MyColumn & Rows.Count).End(xlUp).Row
NewDate = True
For RowCount = StartRow To LastRow
If Range(MyColumn & RowCount) = "" Then
NewDate = True
Else
If NewDate = True Then
MyDate = Range(MyColumn & RowCount)
NewDate = False
Else
Range(MyColumn & RowCount) = MyDate
End If
End If

Next RowCount

End Sub


"WBTKbeezy" wrote:

Hello:

I have a column of data that is a list of dates and times as a schedule.
Each date listed may have several times underneath it (i.e., 4/16/08 could
have 9:00AM, 10AM, 11AM underneath it). I would like to be able to
automatically erase the times and replace them with the date they fall under.
Each date may have anywhere from 0-5 times listed underneath them, but each
date is ALWAYS separated by one blank cell. Is there anyway to do this via a
macro?

Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Conditional Copy Macro

Sub test()
lrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lrow
If InStr(1, Cells(i, 1), "/") 0 Then
dn = Cells(i, 1).End(xlDown).Row
Cells(i, 1).AutoFill _
Destination:=Range("A" & i, "A" & dn), _
Type:=xlFillCopy
i = dn
End If
Next i
End Sub

--
Dan


On Apr 17, 11:47*am, WBTKbeezy
wrote:
Hello:

I have a column of data that is a list of dates and times as a schedule.
Each date listed may have several times underneath it (i.e., 4/16/08 could
have 9:00AM, 10AM, 11AM underneath it). I would like to be able to
automatically erase the times and replace them with the date they fall under.
Each date may have anywhere from 0-5 times listed underneath them, but each
date is ALWAYS separated by one blank cell. Is there anyway to do this via a
macro?

Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Conditional Copy Macro

Hi

This will do what you need. Just change FirstCell to point at the cell in
the TargetArea and LastCell to point to the very last cell in Target column.

Sub ReplaceTime()
Dim TargetRange As Range
Dim StartDate As Date
Dim StartCell As String
Dim LastCell As String

Application.ScreenUpdating = False
StartCell = "A2"
LastCell = "A65536"

Set TargetRange = Range(StartCell, Range(LastCell).End(xlUp))

StartDate = Range(StartCell).Value
For Each r In TargetRange
If IsDate(r.Value) Then
tDate = r.Value
Else
If r.Value < "" Then r.Value = tDate
End If
Next
Application.ScreenUpdating = True
End Sub

Regards,
Per

"WBTKbeezy" skrev i meddelelsen
...
Hello:

I have a column of data that is a list of dates and times as a schedule.
Each date listed may have several times underneath it (i.e., 4/16/08 could
have 9:00AM, 10AM, 11AM underneath it). I would like to be able to
automatically erase the times and replace them with the date they fall
under.
Each date may have anywhere from 0-5 times listed underneath them, but
each
date is ALWAYS separated by one blank cell. Is there anyway to do this via
a
macro?

Thanks.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Conditional Copy Macro

Thanks everyone, these are perfect! (And yes, rick - that is exactly what I
needed, i don't care about the times!)

"Per Jessen" wrote:

Hi

This will do what you need. Just change FirstCell to point at the cell in
the TargetArea and LastCell to point to the very last cell in Target column.

Sub ReplaceTime()
Dim TargetRange As Range
Dim StartDate As Date
Dim StartCell As String
Dim LastCell As String

Application.ScreenUpdating = False
StartCell = "A2"
LastCell = "A65536"

Set TargetRange = Range(StartCell, Range(LastCell).End(xlUp))

StartDate = Range(StartCell).Value
For Each r In TargetRange
If IsDate(r.Value) Then
tDate = r.Value
Else
If r.Value < "" Then r.Value = tDate
End If
Next
Application.ScreenUpdating = True
End Sub

Regards,
Per

"WBTKbeezy" skrev i meddelelsen
...
Hello:

I have a column of data that is a list of dates and times as a schedule.
Each date listed may have several times underneath it (i.e., 4/16/08 could
have 9:00AM, 10AM, 11AM underneath it). I would like to be able to
automatically erase the times and replace them with the date they fall
under.
Each date may have anywhere from 0-5 times listed underneath them, but
each
date is ALWAYS separated by one blank cell. Is there anyway to do this via
a
macro?

Thanks.



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
Conditional copy Idaho Excel User Excel Discussion (Misc queries) 0 August 22nd 06 05:32 PM
Conditional Copy Macro Help Needed [email protected] Excel Programming 1 June 8th 06 09:58 PM
Conditional Copy Paste Macro WH Excel Discussion (Misc queries) 1 March 17th 06 11:02 PM
Conditional copy ledzepe Excel Discussion (Misc queries) 2 March 3rd 06 06:27 PM
Conditional Copy pambear Excel Programming 2 April 8th 04 12:56 AM


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