Filling in the blank cells of raw data

Kerrold

New Member
Joined
Mar 7, 2012
Messages
28
Hi I have some raw data which is basically customer order information with the following column

Date ordered / customer name / item ordered / quantity / unit price /net value

The problem i have is that in the long list of data the date ordered and customer name only appears in the first row of that orders details so if the customer has purchased more than one item after item 1 rows a and b are empty.

I therefore need some code that will look a cell a1 and if there is an entry in that cell look at the row below and if a2 is empty and there is an entry in c2 copy a1:b1 down and repeat this until it gets to the bottom of all of the data.

Many thanks in advance, Kerrold
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Try

Code:
Sub afill()
Dim LR As Long
LR = Range("C" & Rows.Count).End(xlUp).Row
With Range("A1:B" & LR)
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
    .Value = .Value
End With
End Sub
 
Upvote 0
Code:
Sub FillBlanks()
    n = Cells(Rows.Count, 3).End(xlUp).Row
    For r = 1 To n
        If Cells(r, 1) = "" And Cells(r, 3) <> "" Then
            Cells(r, 1) = Cells(r - 1, 1)
            Cells(r, 2) = Cells(r - 1, 2)
        End If
    Next
End Sub
Hope this helps,

Chris.
 
Upvote 0
Code:
Sub M_snb()
    For Each ar In Sheet2.Cells(1).CurrentRegion.Columns(1).SpecialCells(4).Areas
      ar.Value = ar.Cells(1).Offset(-1)
      ar.Offset(, 1) = ar.Cells(1).Offset(-1, 1)
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top