Can you help me to provide VBA code to rename all sheet based on call value available in A1 of each sheet but wanted to pick only 1st there word as sheet name
sub rename ()
for each sht in thisworkbook.worksheets
sht.name=sht.range("A1")
next sht
This VBA is renaming all sheet but I want to capture only first three word from cell A1
For eg. "A1" = "Fund GQ Jan Q1 2019"
so I need sheet name to be "Fund GQ Jan"
A little manipulation with the String will help:
See the use of Left
and Instr
Sub rename()
For Each sht In ThisWorkbook.Worksheets
sht.Name = Left(sht.Range("A1"), InStr(1, sht.Range("A1"), Split(sht.Range("A1"), " ")(3)) - 2)
Next sht
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.