Imported data

H

Help

I have downloaded data from another program into excel. I want to put the
name and total hours worked on the same row. Here's how the data filled into
the
spreadsheet:

Ann Mon 7.5
Tues 7.5
Wed 7.5
Total 22.5

Cathy Mon 7
Wed 8
Thurs 7
Total 22

But, I want it to look like this -
Ann 22.5
Cathy 22

How do I do that?
 
B

Billy Liddel

If it is a daily task the eaiest way is to use a macro. id the data will
always be imported into the sames book copy the code into a VB Module (ALT +
F11, Insert Module) Then return to the book (ALT Q) and run the code.

If the data is imported into a new book the code will not be available
unless you copy the code into your personal.xls

Sub CondenseList()
Dim LastRow As Long, i As Long, thisRow As Long
Dim MyName As String
LastRow = Cells.SpecialCells(xlLastCell).Row
' Place the Total by the names
For i = 1 To LastRow
If Not IsEmpty(Cells(i, 1)) Then
MyName = Cells(i, 1)
thisRow = i
ElseIf Cells(i, 2).Value = "Total" Then
Cells(thisRow, 2).Value = Cells(i, 3).Value
End If
Next
' Clear column 3
Range(Cells(1, 3), Cells(LastRow, 3)).ClearContents
' delete the redundant rows
For i = LastRow To 1 Step -1
If IsEmpty(Cells(i, 1)) Then
Range(Cells(i, 1), Cells(i, 2)).Delete
End If
Next
End Sub

Hope this helps
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top