macro truncating cell on all worksheet.

tuytuy

Board Regular
Joined
Mar 28, 2013
Messages
75
hi,
i wanted to write a macro that would truncate the cell B1 to 10 character from the right. Then rename the sheet with the right bit of the cell. And finally delete both cells. And repeat this process with all sheet in the workbook (they all contain a section number and section description in B1)

E.G.
i have in cell B1 this value:

Section 1 Who - All accounts: 1 record per account


<tbody>
</tbody>
i want the macro to truncate it after section 1 and rename the tab of the sheet with section 1. And then delete both cells (the one with "section 1" and the one with "Who - All accounts: 1 record per account".
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Here what i've got so fare, still need to loop it for all sheets know.

Code:
Sub macro()
ActiveCell = Left(Range("B1"), 9)
ActiveCell = Replace(ActiveCell, " ", "_")
Dim ws1 As Worksheet
Set ws1 = ActiveSheet
ws1.Name = ws1.Range("B1")
Selection.EntireRow.Delete
End Sub
 
Upvote 0

Forum statistics

Threads
1,217,764
Messages
6,138,471
Members
450,141
Latest member
Hal5000

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