Is rich text available for DialogSheet

Formula11

Active Member
Joined
Mar 1, 2005
Messages
468
Office Version
  1. 365
Platform
  1. Windows
Hi, I found this code somewhere a while ago to make it easier to select worksheets
This is useful in the event there are too many sheets and you have to scroll to get to the sheet you need.

DialogSheet is used which I haven't come across before.

Was wondering if rich text is possible with DialogSheet.

Or perhaps may have to create a custom userform?

VBA Code:
Sub pupup_to_select_sheet()
    Dim i As Integer
    Dim posn_from_top As Integer
    Dim sheetCount As Integer
    Dim my_dialog As DialogSheet
    Dim currentSheet As Object
    Dim visbile_count_Sht As Integer    'visible count of sheet
    Dim btn_Width As Integer    'optionbutton width to show description
    Dim No_of_Columns As Integer    'number of column of optionbutton on panel
    Dim sheet_count As Long
    Dim rwnum As Long
    Dim ladj As Long, tadj As Long

    'Add temporary dialog sheet
    Set my_dialog = ActiveWorkbook.DialogSheets.Add

    sheetCount = 0

    posn_from_top = 20
    btn_Width = 100

    sheet_count = ActiveWorkbook.Sheets.Count
    No_of_Columns = sheet_count / 10
    visbile_count_Sht = 0

    For i = 1 To sheet_count
        Set currentSheet = ActiveWorkbook.Sheets(i)
        If currentSheet.Visible = xlSheetVisible Then
            If my_dialog.Name <> currentSheet.Name Then
                visbile_count_Sht = visbile_count_Sht + 1
            End If
        End If
    Next i

    If (Int(visbile_count_Sht / No_of_Columns) + 2) * (No_of_Columns - 1) >= visbile_count_Sht Then No_of_Columns = No_of_Columns - 1

    my_dialog.Visible = xlSheetHidden

    For i = 1 To sheet_count
        Set currentSheet = ActiveWorkbook.Sheets(i)
        'Skip hidden sheets and a temporary dialog sheet
        If currentSheet.Visible = xlSheetVisible Then
            If my_dialog.Name <> currentSheet.Name Then
                rwnum = Int(visbile_count_Sht / No_of_Columns) + 2
                If sheetCount Mod rwnum = 0 And sheetCount <> 0 Then
                    ladj = ladj + btn_Width
                    tadj = tadj - 13 * rwnum
                End If
                sheetCount = sheetCount + 1
                posn_from_top = posn_from_top + 13
                With my_dialog.OptionButtons.Add(78 + ladj, posn_from_top + tadj, btn_Width, 10)
                .Text = currentSheet.Name

                .OnAction = "ActivateSheet"
                End With
            End If
        End If
    Next i

    'Set dialog height, width, and caption
    'seen by the user
    With my_dialog.DialogFrame
        .Height = Application.Max(68, ((rwnum + 2) * 13))
        .Width = (No_of_Columns) * btn_Width
        .Caption = "Select sheet"
    End With
    
    my_dialog.Buttons.Delete

    'Display the dialog box
    my_dialog.Show

    'delete at the end
    'Delete temporary dialog sheet (without a warning)
    Application.DisplayAlerts = False
    my_dialog.Delete
End Sub

Private Sub ActivateSheet()
    Dim ob As Excel.OptionButton
    On Error Resume Next
    Set ob = ActiveWorkbook.DialogSheets(1).OptionButtons(Application.Caller)
    ActiveWorkbook.Sheets(CStr(ob.Text)).Select
    On Error GoTo 0
End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Not an answer to your question, but are you aware that if you right-click on either of the tab navigation arrows in the bottom left corner of the Excel window it brings up a dialogue and you can just click on the name of the sheet you want to go to?

1727742178265.png
 
Upvote 0
Thanks, yes I was aware of that but still have to get there and then scroll.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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