View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Copy Data to Cells, but Stop at Next Non-Empty Cell

Hi,

Right click your sheet tab, view code and paste this in and run it

Sub Stantial()
lastrow = Cells(Cells.Rows.Count, "B").End(xlUp).Row
Set myrange = Range("A1:A" & lastrow)
For Each c In myrange
If c.Offset(1, 0).Value = "" Then
With c.Offset(1, 0)
.Value = c.Value
.NumberFormat = "h:mm"
End With
End If
Next
End Sub

Mike

"Fester" wrote:

I have a spreadsheet with the following data:

Column A Column B
05:00 Item A
Item B
Item C
07:00 Item A
Item B
09:00 Item B
Item C

Each item corresponds with the time in the same block. What I want to
accomplish is have the time move down until it comes to the next
time. Shown below:

05:00 Item A
05:00 Item B
05:00 Item C
07:00 Item A
07:00 Item B
09:00 Item B
09:00 Item C

So it copies the time down until it comes to the next, non-empty
cell. What I'll then do is count the number of item a entries at
specific times (morning vs afternoon) and so on.