clear cells

k_babb

Board Regular
Joined
Mar 28, 2011
Messages
71
hi i really need some help with a macro i have a massive spread sheet
which has a company name then a cell gap then the next 3 cells have an address then there are different amounts of cells i would like a macro to copy the company name over the address and the blank cells until it finds the next company name is there anyway to do this
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
If you were just copying into blank cells it would be easier, but to do what you're asking, you'll need a reliable way of distinguishing company names from addresses.
 
Upvote 0
Any chance of a small amount of sample data and expected results?
 
Upvote 0
<table border="0" cellpadding="0" cellspacing="0" width="192"><col style="width:48pt" span="3" width="64"> <tbody><tr style="height:15.0pt" height="20"> <td colspan="2" style="height:15.0pt;mso-ignore:colspan; width:96pt" height="20" width="128">company1</td> <td style="width:48pt" width="64">company1</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company1</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">add</td> <td>
</td> <td>company1</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">add</td> <td>
</td> <td>company1</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">add</td> <td>
</td> <td>company1</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company1</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company1</td> </tr> <tr style="height:15.0pt" height="20"> <td colspan="2" style="height:15.0pt;mso-ignore:colspan" height="20">company2</td> <td>company2</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company2</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">add</td> <td>
</td> <td>company2</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">add</td> <td>
</td> <td>company2</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">add</td> <td>
</td> <td>company2</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company2</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company2</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company2</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company2</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company2</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company2</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company2</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company2</td> </tr> <tr style="height:15.0pt" height="20"> <td colspan="2" style="height:15.0pt;mso-ignore:colspan" height="20">company3</td> <td>company3</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company3</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">add</td> <td>
</td> <td>company3</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">add</td> <td>
</td> <td>company3</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">add</td> <td>
</td> <td>company3</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company3</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company3</td> </tr> <tr style="height:15.0pt" height="20"> <td style="height:15.0pt" height="20">
</td> <td>
</td> <td>company3</td> </tr> <tr style="height:15.0pt" height="20"> <td colspan="2" style="height:15.0pt;mso-ignore:colspan" height="20">company4</td> <td>
</td> </tr> </tbody></table>
 
Upvote 0
how do i upload a sample spread sheet
You cannot upload a sheet. You can post small screen shots - see my signature block.

However, what you have shown is OK but what would the corresponding result look like?

Edit: Ignore my last sentence, I hadn't seen your last post. :)
 
Upvote 0
what i have uploaded is what i want it to look like. the left hand side is what it looks like now, the right hand side is what i want it to look like if possible
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,486
Members
452,917
Latest member
MrsMSalt

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