Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Reindexing worksheet numbers

How would I reindex worksheet numbers using VBA code?

Ex.

sheet1, sheet7, sheet11, to sheet1, sheet2, sheet3
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Reindexing worksheet numbers

Sub Renamesheets()
Dim i As Long, j As Long
Dim k As Long, bQuit As Boolean
l = 0
For i = 1 To 26
For j = 1 To 26
For k = 1 To 27
l = l + 1
Worksheets(l).Name = Chr(i + 64) & _
Chr(j + 64) & Chr(k + 64)
If l = Worksheets.Count Then
bQuit = True
Exit For
End If
Next
If bQuit Then Exit For
Next
If bQuit Then Exit For
Next
For i = 1 To Worksheets.Count
Worksheets(i).Name = "Sheet" & i
Next

End Sub

--
Regards,
Tom Ogilvy


"GaryMay" wrote:

How would I reindex worksheet numbers using VBA code?

Ex.

sheet1, sheet7, sheet11, to sheet1, sheet2, sheet3

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Reindexing worksheet numbers

In the Project Box in VBA I had:
sheet1(name)
sheet19(name)
sheet2(name)
sheet21(name)
sheet22(name)
sheet3(name)

Your code gave me:
sheet1(AAB)
sheet19(AAA)
sheet2(AAE)
sheet21(AAH)
sheet22(AAG)
sheet3(AAC)

I need it to reindex like this say:
sheet1(name)
sheet2(name)
sheet3(name)
sheet4(name)
sheet5(name)
sheet6(name)


Or, to reset so that the next sheet will always be sheet7.

Thanks for the effort.







"Tom Ogilvy" wrote:

Sub Renamesheets()
Dim i As Long, j As Long
Dim k As Long, bQuit As Boolean
l = 0
For i = 1 To 26
For j = 1 To 26
For k = 1 To 27
l = l + 1
Worksheets(l).Name = Chr(i + 64) & _
Chr(j + 64) & Chr(k + 64)
If l = Worksheets.Count Then
bQuit = True
Exit For
End If
Next
If bQuit Then Exit For
Next
If bQuit Then Exit For
Next
For i = 1 To Worksheets.Count
Worksheets(i).Name = "Sheet" & i
Next

End Sub

--
Regards,
Tom Ogilvy


"GaryMay" wrote:

How would I reindex worksheet numbers using VBA code?

Ex.

sheet1, sheet7, sheet11, to sheet1, sheet2, sheet3

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Reindexing worksheet numbers

first, no my code wouldn't do what you said unless you altered it. It gives
the 3 letter names as intermediate values to avoid naming conflicts. It then
renames all the sheets as sheet1, sheet2, sheet3, etc.

This does what almost anyone here would say your post asks for.

Now it appears you want to talk about the codename of the sheet. That was
my original assumption in the first thread you started related to this and I
have you a reference to Chip Pearson's page with the proper code to use to
rename the codename of a sheet.

You could combine that code with the code I posted in this thread to
accomplish what you want to do.

--
Regards,
Tom Ogilvy




"GaryMay" wrote:

In the Project Box in VBA I had:
sheet1(name)
sheet19(name)
sheet2(name)
sheet21(name)
sheet22(name)
sheet3(name)

Your code gave me:
sheet1(AAB)
sheet19(AAA)
sheet2(AAE)
sheet21(AAH)
sheet22(AAG)
sheet3(AAC)

I need it to reindex like this say:
sheet1(name)
sheet2(name)
sheet3(name)
sheet4(name)
sheet5(name)
sheet6(name)


Or, to reset so that the next sheet will always be sheet7.

Thanks for the effort.







"Tom Ogilvy" wrote:

Sub Renamesheets()
Dim i As Long, j As Long
Dim k As Long, bQuit As Boolean
l = 0
For i = 1 To 26
For j = 1 To 26
For k = 1 To 27
l = l + 1
Worksheets(l).Name = Chr(i + 64) & _
Chr(j + 64) & Chr(k + 64)
If l = Worksheets.Count Then
bQuit = True
Exit For
End If
Next
If bQuit Then Exit For
Next
If bQuit Then Exit For
Next
For i = 1 To Worksheets.Count
Worksheets(i).Name = "Sheet" & i
Next

End Sub

--
Regards,
Tom Ogilvy


"GaryMay" wrote:

How would I reindex worksheet numbers using VBA code?

Ex.

sheet1, sheet7, sheet11, to sheet1, sheet2, sheet3

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Reindexing worksheet numbers

No problem my friend. I did not change your code. Thanks for your effort.

"Tom Ogilvy" wrote:

first, no my code wouldn't do what you said unless you altered it. It gives
the 3 letter names as intermediate values to avoid naming conflicts. It then
renames all the sheets as sheet1, sheet2, sheet3, etc.

This does what almost anyone here would say your post asks for.

Now it appears you want to talk about the codename of the sheet. That was
my original assumption in the first thread you started related to this and I
have you a reference to Chip Pearson's page with the proper code to use to
rename the codename of a sheet.

You could combine that code with the code I posted in this thread to
accomplish what you want to do.

--
Regards,
Tom Ogilvy




"GaryMay" wrote:

In the Project Box in VBA I had:
sheet1(name)
sheet19(name)
sheet2(name)
sheet21(name)
sheet22(name)
sheet3(name)

Your code gave me:
sheet1(AAB)
sheet19(AAA)
sheet2(AAE)
sheet21(AAH)
sheet22(AAG)
sheet3(AAC)

I need it to reindex like this say:
sheet1(name)
sheet2(name)
sheet3(name)
sheet4(name)
sheet5(name)
sheet6(name)


Or, to reset so that the next sheet will always be sheet7.

Thanks for the effort.







"Tom Ogilvy" wrote:

Sub Renamesheets()
Dim i As Long, j As Long
Dim k As Long, bQuit As Boolean
l = 0
For i = 1 To 26
For j = 1 To 26
For k = 1 To 27
l = l + 1
Worksheets(l).Name = Chr(i + 64) & _
Chr(j + 64) & Chr(k + 64)
If l = Worksheets.Count Then
bQuit = True
Exit For
End If
Next
If bQuit Then Exit For
Next
If bQuit Then Exit For
Next
For i = 1 To Worksheets.Count
Worksheets(i).Name = "Sheet" & i
Next

End Sub

--
Regards,
Tom Ogilvy


"GaryMay" wrote:

How would I reindex worksheet numbers using VBA code?

Ex.

sheet1, sheet7, sheet11, to sheet1, sheet2, sheet3

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date of worksheet comes out numbers on other linked worksheet Deb A[_2_] Excel Worksheet Functions 2 July 16th 08 10:41 PM
Searching numbers in Worksheet Johncobb45 Excel Worksheet Functions 6 August 5th 06 08:00 PM
Searching numbers in Worksheet? Johncobb45 Excel Worksheet Functions 3 July 28th 06 07:07 PM
How do i change all numbers in my worksheet Leo258 Excel Worksheet Functions 2 January 21st 05 03:32 PM
Getting rid of all negative numbers on a worksheet abxy Excel Programming 2 January 10th 04 01:49 AM


All times are GMT +1. The time now is 06:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"