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

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Ok, it probably contains a null string, try
VBA Code:
Sub trebor()
   With Range("C3:D" & Range("A" & Rows.Count).End(xlUp).Row)
      .Value = .Value
      .SpecialCells(xlBlanks).FormulaR1C1 = "=r[-1]c"
      .Value = .Value
   End With
End Sub
 
Upvote 0
Solution
Ok, it probably contains a null string, try
VBA Code:
Sub trebor()
   With Range("C3:D" & Range("A" & Rows.Count).End(xlUp).Row)
      .Value = .Value
      .SpecialCells(xlBlanks).FormulaR1C1 = "=r[-1]c"
      .Value = .Value
   End With
End Sub
Perfect thank you
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Another way :​
VBA Code:
Sub Demo2()
    Dim V, R&
    With Range("C3:D" & [A1].CurrentRegion.Rows.Count)
        V = .Value2
    For R = 2 To .Rows.Count
    For C = 1 To 2
        If V(R, C) = "" Then V(R, C) = V(R - 1, C)
    Next C, R
       .Value2 = V
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,826
Messages
6,181,192
Members
453,021
Latest member
pingpong7117

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