Merging two columns

Shymanas

New Member
Joined
Aug 12, 2009
Messages
42
Hi,

I have two columns example:

<table border="0" cellpadding="0" cellspacing="0" width="128"><colgroup><col style="width:48pt" span="2" width="64"> </colgroup><tbody><tr style="height:15.0pt" height="20"> <td style="height:15.0pt;width:48pt" height="20" width="64">AA</td> <td style="width:48pt" width="64">
</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>BB</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">CC</td> <td>DD</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>EE</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>FF</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">GG</td> <td>HH</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">JJ</td> <td>
</td> </tr> </tbody></table>
I want to move the comtents from column B into column A, only if the cell in A is blank.

So the end result I want is as follows:

<table border="0" cellpadding="0" cellspacing="0" width="128"><colgroup><col style="width:48pt" span="2" width="64"> </colgroup><tbody><tr style="height:15.0pt" height="20"> <td style="height:15.0pt;width:48pt" height="20" width="64">AA</td> <td style="width:48pt" width="64">
</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">BB</td> <td>
</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">CC</td> <td>DD</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">EE</td> <td>
</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">FF</td> <td>
</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">GG</td> <td>HH</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">JJ</td> <td>
</td> </tr> </tbody></table>
Thanks
Shai
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try

Code:
Sub b()
Dim c As Range
For Each c In Columns("A").SpecialCells(xlCellTypeBlanks)
    c.Value = c.Offset(, 1).Value
    c.Offset(, 1).ClearContents
Next c
End Sub
 
Upvote 0
It isn't a formula, it is a macro.

Press ALT + F11 to open the Visual Basic Editor, select Module from the Insert menu then paste the code into the white space on the right. Press ALT + Q to close the code window.

Press ALT + F8, in the window that pops up double click b.
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,152
Members
452,891
Latest member
JUSTOUTOFMYREACH

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