Textbox value - rename worksheet with

L

LRay67

I have 10 tabs that I will need to rename from a textbox (not the range in
the code below). The following code has to be ran first, then backtrack to
rename the appropriate tabs to the value in the textbox. Anyone have any
ideas?

Range("P5:R5").Copy
For sh = 2 To Sheets.Count
If Sheets(sh).Name Like ("Request*") Then
ActiveSheet.Paste Destination:=Sheets(sh).Range("P5:R5")
End If
Next
End Sub
 
M

Mike

Dim wsName As String
Dim WS_Count As Integer
Dim i As Integer
WS_Count = ActiveWorkbook.Worksheets.Count
' Begin the loop.
For i = 1 To WS_Count
wsName = Textbox1.value & i
On Error Resume Next
ActiveWorkbook.Worksheets(i).Name = & wsName
Next i
 
L

LRay67

Mike,

I tried the code below, but it is not working. The
ActiveWorkbook.Worksheets(i).Name = & wsName (code) comes up in red.
Another co-worker & I have been trying to figure this out, but are unable to.
Any suggestions??
 
M

Mike

Try this
Sub WorksheetLoop()
Dim wsName As String
Dim WS_Count As Integer
Dim i As Integer
WS_Count = _
ActiveWorkbook.Worksheets.Count
' Begin the loop.
For i = 1 To WS_Count
wsName = "wk" & i
On Error Resume Next
ActiveWorkbook.Worksheets(i).Name = _
wsName
Next i
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top