Deleting blank cells

sebas35

New Member
Joined
May 24, 2019
Messages
3
Hi there,

Maybe this is an easy task for you guys, but I've been struggling with it. Basically, I need to converter the table 1 into the table 2.

Thank you for any help!



YES
NO
YESNOYES
NO
Table 2
YES
NO
YESNOYES
NOYES

<colgroup><col style="mso-width-source:userset;mso-width-alt:3868;width:82pt" width="109"> <col style="width:48pt" width="64" span="10"> <col style="mso-width-source:userset;mso-width-alt:3157;width:67pt" width="89"> </colgroup><tbody>
[TD="width: 109"]Table 1[/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 64"][/TD]
[TD="width: 89"][/TD]

[TD="class: xl63"]A1[/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"]NO[/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl65"] [/TD]

[TD="class: xl66"]A2[/TD]

[TD="class: xl67"] [/TD]

[TD="class: xl66"]A3[/TD]

[TD="class: xl67"] [/TD]

[TD="class: xl66"]A4[/TD]

[TD="class: xl67"] [/TD]

[TD="class: xl66"]A5[/TD]

[TD="class: xl67"]YES[/TD]

[TD="class: xl68"]A6[/TD]
[TD="class: xl69"]YES[/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"]YES[/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl70"] [/TD]

[TD="class: xl63"]A1[/TD]
[TD="class: xl64"]NO[/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl64"] [/TD]
[TD="class: xl65"] [/TD]

[TD="class: xl66"]A2[/TD]

[TD="class: xl67"] [/TD]

[TD="class: xl66"]A3[/TD]

[TD="class: xl67"] [/TD]

[TD="class: xl66"]A4[/TD]

[TD="class: xl67"] [/TD]

[TD="class: xl66"]A5[/TD]

[TD="class: xl67"] [/TD]

[TD="class: xl68"]A6[/TD]
[TD="class: xl69"]YES[/TD]
[TD="class: xl69"]YES[/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl69"] [/TD]
[TD="class: xl70"] [/TD]

</tbody>
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
If your cells are truly blank/empty then try...

Code:
Cells.SpecialCells(xlCellTypeBlanks).Delete Shift:=xlToLeft

or manually

Select all cells
Ctrl + G
Click Special
Check Blanks
Ok
Right Click
Delete
Check Shift cells left
Ok
 
Last edited:
Upvote 0
If Table 1 appears just like your illustration with it starting in A1 cell (with "A1", etc. through "L1") and is in A1:L8,

Table 2 can be anywhere with the A column repeated (e.g., A8 to A13), then put this formula in B8 and fill across to L and down to row 13:

NOTE: It's an array formula, so you have to enter it using CTRL+SHIFT+Enter

Code:
=IFERROR(INDEX($B1:$L1,SMALL(IF($B1:$L1<>"",COLUMN($B1:$L1)-COLUMN($B1)+1),COLUMN()-1)),"")

HTH
 
Last edited:
Upvote 0
Hi kweaver,

Thank you for advising. Your formula worked only for one row in my matrix. Actually, I'd want the same procedure for every single row in the matriz (table 1) because my real matrix has about 2500 rows!

Thank you!
 
Upvote 0
Did you put the ARRAY formula in B8 and FILL across and down?

Clip0021.jpg
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,161
Members
453,021
Latest member
Justyna P

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