Computing.Net > Forums > Programming > Using VB to rename Excel sheet tabs

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Using VB to rename Excel sheet tabs

Reply to Message Icon

Original Message
Name: Shawn
Date: March 28, 2003 at 12:08:59 Pacific
Subject: Using VB to rename Excel sheet tabs
OS: 2000
CPU/Ram: pent 4
Comment:

In Excel i want to rename the worksheet tab using a VB macro. I want it to copy a cell on the worksheet and use it as the worksheet name. It needs to be variable because i want to copy the worksheet, increment the cell value by one, and have the new worksheet named the new cell value.
Here is the code:

ActiveSheet.Copy After:=ActiveSheet

ActiveSheet.Previous.Select
Range("j3").Copy
ActiveSheet.Next.Select
Range("j3").PasteSpecial xlPasteValues
Range("j3").Value = Range("j3").Value + 1
ActiveSheet.Name = Range("j3").Value

It is the last line that is giving me trouble.

Thanks for any help.



Report Offensive Message For Removal


Response Number 1
Name: egkenny
Date: March 28, 2003 at 17:13:15 Pacific
Reply: (edit)

ActiveSheet.Name = Format(Range("j3").Value, "#")


Report Offensive Follow Up For Removal

Response Number 2
Name: shawn
Date: March 31, 2003 at 10:30:51 Pacific
Reply: (edit)

It worked perfectly, I did change the format to mm-dd-yy.

Thank you egkenny!


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software