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".
 

Some videos you may like

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
To exclude the rightmost 10 characters from the value in a cell:

Left(cell.Value, Len(cell.Value)-10)
 

tuytuy

Board Regular
Joined
Mar 28, 2013
Messages
75
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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,519
Messages
5,602,141
Members
414,505
Latest member
quoctrungvu99

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
Top