VBA to copy down data for blank cells - repeat for entire data set.

Trebor200

Board Regular
Joined
Apr 21, 2015
Messages
67
Office Version
  1. 365
Platform
  1. Windows
Hi All, due to the way the raw data file is presented where duplicate values are merged, i have the need to find blank rows and coipy down data.. example below of raw data with expected results..

Thank you for your help.

VBA Query.xlsx
ABCDEFGHIJ
1Raw DataFormatted data
2IDDateNumberDescrIDDateNumberDescr
3812649106/03/20176910209ABC123812649106/03/20176910209ABC123
4850913313/09/2018850913313/09/20186910209ABC123Data Copied down
5850913313/09/2018850913313/09/20186910209ABC123Data Copied down
6852981804/10/20187321000ABC345852981804/10/20187321000ABC345
7852981805/10/2018852981805/10/20187321000ABC345Data Copied down
8852981805/10/2018852981805/10/20187321000ABC345Data Copied down
9852981805/10/2018852981805/10/20187321000ABC345Data Copied down
10858303022/02/20197682566ABBB858303022/02/20197682566ABBB
11887068507/05/20207970956GGHJJJ887068507/05/20207970956GGHJJJ
12888652712/08/20207970956GGHJJJ888652712/08/20207970956GGHJJJ
138002673513/08/20207970956GGHJJJ8002673513/08/20207970956GGHJJJ
148003060713/08/20207970956GGHJJJ8003060713/08/20207970956GGHJJJ
158005973430/04/20207970956GGHJJJ8005973430/04/20207970956GGHJJJ
168007733729/06/20207970956GGHJJJ8007733729/06/20207970956GGHJJJ
178008416913/10/20207970956GGHJJJ8008416913/10/20207970956GGHJJJ
188009236129/10/20207970260GHKIYUML8009236129/10/20207970260GHKIYUML
198014397217/08/20217486852GDHDYEYYE8014397217/08/20217486852GDHDYEYYE
208015018327/08/20207254399JSJSJSJJS8015018327/08/20207254399JSJSJSJJS
218015333711/09/20207714398KSJKSKSKI8015333711/09/20207714398KSJKSKSKI
228017050501/10/20207419515KJSJSYYEW8017050501/10/20207419515KJSJSYYEW
238021006304/01/20218021006304/01/20217419515KJSJSYYEWData Copied down
248021006308/01/20217692106BSTEBB8021006308/01/20217692106BSTEBB
258025986611/05/20217970260ASRWGH8025986611/05/20217970260ASRWGH
268026250504/03/20217772620DDDDD8026250504/03/20217772620DDDDD
278026528209/03/20217772620DDDDD8026528209/03/20217772620DDDDD
288026964716/03/20217772620DDDDD8026964716/03/20217772620DDDDD
298026966407/04/20217970260WQDQWD8026966407/04/20217970260WQDQWD
308027354522/03/20217970956WQDQWD8027354522/03/20217970956WQDQWD
318027459507/04/20217772620WQDQWD8027459507/04/20217772620WQDQWD
328027536801/06/20217970956WQDQWD8027536801/06/20217970956WQDQWD
338028555917/06/20217772620WQDQWD8028555917/06/20217772620WQDQWD
Sheet1
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
How about
VBA Code:
Sub trebor()
   With Range("C3:D" & Range("A" & Rows.Count).End(xlUp).Row)
      .SpecialCells(xlBlanks).FormulaR1C1 = "=r[-1]c"
      .Value = .Value
   End With
End Sub
 
Upvote 0
How about
VBA Code:
Sub trebor()
   With Range("C3:D" & Range("A" & Rows.Count).End(xlUp).Row)
      .SpecialCells(xlBlanks).FormulaR1C1 = "=r[-1]c"
      .Value = .Value
   End With
End Sub
Hi thanks for quick reply.. i have tried this and get a run time 1004 error - stops at .SpecialCells(xlBlanks).FormulaR1C1 = "=r[-1]c" i am using O365
 
Upvote 0
Hi, according to the attachment for starters :​
VBA Code:
Sub Demo1()
                 Dim Rg As Range
    With Range("C3:D" & [A1].CurrentRegion.Rows.Count)
        If Application.CountA(.Cells) < .Cells.CountLarge Then
            Application.ScreenUpdating = False
            For Each Rg In .SpecialCells(4).Areas:  Rg.Rows(0).Copy Rg:  Next
            Application.ScreenUpdating = True
        End If
    End With
End Sub
 
Upvote 0
Hi, according to the attachment for starters :​
VBA Code:
Sub Demo1()
                 Dim Rg As Range
    With Range("C3:D" & [A1].CurrentRegion.Rows.Count)
        If Application.CountA(.Cells) < .Cells.CountLarge Then
            Application.ScreenUpdating = False
            For Each Rg In .SpecialCells(4).Areas:  Rg.Rows(0).Copy Rg:  Next
            Application.ScreenUpdating = True
        End If
    End With
End Sub
Thanks reply, code runs but finishes without doing anything ?
 
Upvote 0
As my demonstration well works with your attachment so your 'blank' cells are not really blank …​
If any other helper find a way I will need you link your workbook on a files host website like Dropbox …​
 
Upvote 0
No Cells were found
Then the cells are not empty. In another cell put
Excel Formula:
=CODE(C4)
change the C4 to one of the "empty" cells, what does it return?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,323
Members
452,635
Latest member
laura12345

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