Errors in Macro to Sort Sheets by Custom List

tamsidea

New Member
Joined
Mar 28, 2017
Messages
2
I have combined solutions from several posts to help write a macro to sort a variable number of sheets using a custom list created from a range entered on one master recap sheet. It's am very close but still have 2 issues I can't seem to get past.* Below my 2 questions I am copying the code I am using. Any help would be greatly appreciated!

1. * The code I found to allow for a variable number of tabs is skipping the last line of my range. I suspect that is because of the ".Offset(-1, 0)" portion of the code below, but when I take that out it hung up sooner.


2. * My tabs are named using an inventory code that may or may not contain alphanumeric characters. Except for the very last line, my macro is working up until it comes to the first sheet named using only numbers - no letters.* I don't know if I need the code to treat the number as text or a value or how to accomplish either.*


Code:
Sub SortTab()

'

' SortTab Macro

' Sort tabs by recap order

Dim SortOrder As Variant

Dim Ndx As Long

With Sheets("LOV RECAP").Range(Range("E12"), Range("E12").End(xlDown).Offset(-1, 0))

*** For Ndx = .Cells.Count To 1 Step -1

******* Sheets(.Cells(Ndx).Value).Move Before:=Sheets(3)

*** Next Ndx

End With

End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I have found a solution for question number 1 but still need help with #2!!!
I changed ".Offset(-1, 0)" to ".Offset(0, 0))" and the macro no longer skips the last line.
Can anyone help me please with making this macro not hang up on the tabs named using only numerals?
 
Upvote 0

Forum statistics

Threads
1,223,714
Messages
6,174,055
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top