View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.setup
Bob Phillips
 
Posts: n/a
Default Macro to convert Name of worksheet

Well spotted. And you did it yourself, which is a better all round :-))

Bob


"G" wrote in message
...
It works (just needed to change ws.name to wks.name since it's wks after
dim). Thanks for the help!!!!

"G" wrote:

I used both your original example and the modified version below.

Neither
seems to run. I get no error msg or any results. I understand what the

code
is trying to do, I'm I forgetting something? Thanks again!

Sub Rename()

Dim iPos As Long
Dim wks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
On Error Resume Next
iPos = Application.Match(ws.Name, Range("BrokerInfo!a2:a84"), 0)
On Error GoTo 0
If iPos 0 Then
ws.Name = Range("BrokerInfo!b2:b84").Cells(iPos, 1)
End If
Next wks
End Sub



"Bob Phillips" wrote:


Dim iPos As Long
Dim wks As Worksheet

For Each wks In ActiveWorkbook.Worksheets
On Error Resume Next
iPos = Application.Match(wks.Name, Range("LongNames"), 0)
On Error GoTo 0
If iPos 0 Then
wks.Name = Range("ShortNames").Cells(iPos, 1)
End If
Next wks


--

HTH

RP
(remove nothere from the email address if mailing direct)


"G" wrote in message
...
I want to change the name of all the worksheets by using a table in
another
worksheet. The table contains one column for long names and another
column
for short names. When the current worksheet name matches the long

name
column, the name is change to the short name.

Thanks,
G