I am using the code below to make navigation through workbook easier. However, after running the macro cursor movement is odd (restricted range and jumping). In addition the workbook does not close when clicking on the red "x" to close the window. Further, the group and ungroup icons (for hiding or expanding rows and columns) does not work. It appears that somehow "control" is still in VBA as supposed to normal Excel. All help seriously appreciated.
Userform code:
Option Explicit
Option Base 1
Private Sub UserForm_Initialize()
Dim ShList()
Dim ShCount As Integer
Dim x As Integer
Dim ListPos As Integer
ShCount = ActiveWorkbook.Sheets.Count
ReDim Preserve ShList(1 To ShCount)
For x = 1 To ShCount
If Sheets(x).Name = ActiveSheet.Name Then
ListPos = x - 1
End If
ShList(x) = Sheets(x).Name
Next x
With ListBox1
.List = ShList
.ListIndex = ListPos
End With
End Sub
Private Sub CommandButton1_Click()
Sheets(ListBox1.Value).Activate
Unload UserForm1
End Sub
Click button to activate code:
Option Explicit
Sub WorksheetSelect_Click()
UserForm1.Show
End Sub