JSON to CSV - Repeat all row items

Seba Robles

Board Regular
Joined
May 16, 2018
Messages
73
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hello,

I have a JSON file that I converted to CSV using an online converter. When I open the CSV file, I have all the data but some rows have blank cells that I want filled. (See image below)

sXsmecP.jpg


Notice how rows 2 through 8, and row 14 are single row items. However, rows 9 through 10 and the rest highlighted in yellow have blank cells.

Take row 9 for example, column B (name) would be the parent - column H (card sets set cod) would be the child). Rows 10 and 11 belong to the parent on row 9, so I want those filled too with the information. Like, repeat the parent information for the cases that apply. (see image below for desired output)

Qcdkp0b.jpg


Now, I've never worked with JSON before so I'm not sure if what needs to be corrected is in the JSON code, but this is a snippet of how the JSON code is written;

2cXNULP.png


Any help or pointers will be greatly appreciated!!!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
VBA Code:
sub s_data_fix()
Dim lastrow1 As Integer
lastrow1 = Cells(Rows.Count, "H").End(xlUp).Row
Dim int1 As Integer
for int1= 2 to lastrow1
if len(trim(ltrim(cells(int1,"A").value))) < 1 then
   cells(int1,"A").value = cells(int1-1,"A").value
   cells(int1,"B").value = cells(int1-1,"B").value
   cells(int1,"C").value = cells(int1-1,"C").value
   cells(int1,"D").value = cells(int1-1,"D").value
   cells(int1,"E").value = cells(int1-1,"E").value
   cells(int1,"F").value = cells(int1-1,"F").value
   cells(int1,"A").value = cells(int1-1,"A").value
end if
next int1
End sub
if this helps you, pl mark this as solution for the future readers of this thread.
 
Upvote 0
Another option
VBA Code:
Sub SebaRobles()
   Dim Rng As Range
   
   For Each Rng In Range("A:A").SpecialCells(xlBlanks).Areas
      Rng.Offset(-1).Resize(Rng.Count + 1, 6).FillDown
   Next Rng
End Sub
 
Upvote 0
Solution
I tried both approaches and they worked. However, there are cells that need to be filled down from columns L through AI as well so Fluff's approach would be easier to code.

I modified the code so that it also fills down the remaining columns

VBA Code:
Sub FillDown_BlankRows()
   Dim Rng As Range
     
   For Each Rng In Range("A:A").SpecialCells(xlBlanks).Areas
      Rng.Offset(-1).Resize(Rng.Count + 1, 6).FillDown
      Rng.Offset(-1, 11).Resize(Rng.Count + 1, 23).FillDown
   Next Rng
   
End Sub

Thank you both!!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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