• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to copy & rename worksheet using combo box value

Mr.Karr

Member
Hello,

Can anyone please provide a code snippet to copy & rename a particular workbook using combo box value.

In detail: User has an activity to copy a particular worksheet--> rename it. Since I'm using a combo box to read available sheetnames.
Then there is a textbox so user can enter "New Sheetname"
As per the listbox, the newly moved sheet should be named as.

Anyone pls any help?

Thanks in advance.
 
Lots of ways to do this, but the syntax would be something like:
Code:
'Assumes this code is being run from a UserForm, hence the Me object
Dim newName As String
Dim oldName As String

newName = Me.TextBox1.Value
oldName = Me.ComboBox1.Value

Worksheets(oldName).Name = newName
 
@Luke M : it works like a breeze.
But there is a step probably I missed out to elaborate.
Copy the combo box1 sheet and rename with textbox1

Can you please help?
 
Sure thing, just a small ammendment
Code:
Dim newName As String
Dim oldName As String

newName = Me.TextBox1.Value
oldName = Me.ComboBox1.Value

Worksheets(oldName).Copy
ActiveSheet.Name = newName
 
Back
Top