PDA

View Full Version : Macros in Excel



Natzsy
08-25-2011, 12:02 PM
Hi,
I am new to this forum and very new to Macros.
I really need some assitance with a spreadsheet that i use on a monthly basis.
I have attached a sample of this sheet and upon perusing you will notice that each entry occupies up to 5 rows.
Can Macros help me to get the entries into 1 Row?

Aussiebear
08-25-2011, 01:31 PM
How is this spreadsheet currently prepared? Is it imported into Excel?

Natzsy
08-26-2011, 05:42 AM
Hi
The information is extracted from Oracle as a text file which is then converted to an excel file.

Bob Phillips
08-26-2011, 06:16 AM
Public Sub ProcessData()
Dim Lastrow As Long
Dim Lastcol As Long
Dim i As Long, j As Long
Dim cell As Range

Application.ScreenUpdating = False

With ActiveSheet

Lastrow = .Cells(.Rows.Count, "B").End(xlUp).Row
Lastcol = .Range("A1").End(xlToRight).Column
For i = Lastrow To 3 Step -1

If Cells(i, "A").Value2 = "" Then

For j = 2 To Lastcol

If .Cells(i, j).Value <> "" Then

.Cells(i - 1, j).Value = .Cells(i - 1, j).Value & " " & .Cells(i, j).Value
End If
Next j
.Rows(i).Delete
End If
Next i
End With

Application.ScreenUpdating = True
End Sub

Aussiebear
08-27-2011, 02:30 AM
Not bad Bob, but it leaves the value 12613 as a value below the data in column G.

Bob Phillips
08-27-2011, 04:42 PM
I figured that one untended item is not too big a chore to tidy up manually!