sorting with macro button
So, you have a sheet that contains all of your worksheets and then a
button to open the sheet? If so, why not just create a table of
contents with hyperlinks to all of the sheets. That should allow you
to sort without any problems.
Sub createTOC()
Dim ws As Worksheet, wsNw As Worksheet
Dim n As Integer
Set wsNw = ActiveWorkbook.Worksheets _
.Add(Befo=ActiveWorkbook.Sheets(1))
With wsNw
starter:
On Error GoTo errHandler
.Name = "TOC"
On Error GoTo 0
.[A1] = "Table Of Contents"
.[A2] = ActiveWorkbook.Name & " Worksheets"
.[A1].Font.Size = 14
.[A2].Font.Size = 10
n = 4
For Each ws In ActiveWorkbook.Worksheets
If ws.Name < .Name And ws.Visible = True Then
.Cells(n, 1) = ws.Name
.Hyperlinks.Add _
Anchor:=.Cells(n, 1), _
Address:="", _
SubAddress:="'" & ws.Name & "'!A1"
n = n + 1
End If
Next
End With
Columns("A:A").EntireColumn.AutoFit
Exit Sub
errHandler: Application.DisplayAlerts = False
Sheets("TOC").Delete
Application.DisplayAlerts = True
GoTo starter
End Sub
vcff wrote:
I had a workbook with 100 worksheets. As this is a big workbook, in order for
me to get to the correct worksheet, I had created 4 menus which were placed
in such an order that at all times, I will be able to see one menu when
working in this workbook. Menu1 is the worksheet which I list or amend the
title of the 100 worksheets while the other 3 menus will created by using the
"=" sign.
In menu1, column A is the 100 worksheets title.
Under column B, I had created a macro button for each of the 100 worksheets.
eg A1 Expenses B1 (a macro button which will bring me to the correct
worksheet)
When I do a sorting under menu1 by selecting column A & B, I had a problem
on the other 3 menus. The macro buttons under column B does not follow column
A during the sorting.
eg I am in menu3
A1 address but B1 button will direct me to the expenses worksheet
Pls help
tnks
|