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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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,214,839
Messages
6,121,892
Members
449,058
Latest member
Guy Boot

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