• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

copy paste ad naseum

Lawrence429

New Member
I have a sheet where A1:A2 are merged, A3:A4 are merged and so on. In each merged cell is a machine and when I unmerged this column to work in a Pivot Table, I have a machine then a blank, then a machine, then a blank and so on. How can I QUICKLY tell Excel If the cell is empty copy the one above?
Thank you
Lawrence
 
If there is nothing else in the sheet, why not just delete the row with the blank cell ?

Code:
Option Explicit

Sub DeleteBlankRows1()

'Deletes the entire row within the selection if the ENTIRE row contains no data.
'http://www.ozgrid.com/VBA/VBACode.htm


'We use Long in case they have over 32,767 rows selected.

Dim i As Long

    'We turn off calculation and screenupdating to speed up the macro.

    With Application

        .Calculation = xlCalculationManual

        .ScreenUpdating = False

    'We work backwards because we are deleting rows.

    For i = Selection.Rows.Count To 1 Step -1

        If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then

            Selection.Rows(i).EntireRow.Delete

        End If

    Next i

        .Calculation = xlCalculationAutomatic

        .ScreenUpdating = True

    End With

End Sub

OR .. If you really do need to fill the blank cell with the data from above ...

Code:
Option Explicit

Sub Fill_Blanks()
  Dim cel          As Range
  Dim LR          As Long
  Dim Temp        As String
  LR = Range("A" & Rows.Count).End(xlUp).Row
  For Each cel In Range("A1:A" & LR)
      If Not IsEmpty(cel) Then
        Temp = cel
      Else
        cel.Value = Temp
      End If
  Next
End Sub
 
FYI if you want to use latin in a sentence, use it properly and without capitalization errors. Latin. Also the word 'wthout' is spelled 'without'.

Just saying ....
 
Back
Top