Create dynamic window launched from userform

paipimenta

Board Regular
Joined
Apr 7, 2010
Messages
103
Hello,

I have a userform that I launch from a workbook that is used for non-technical users to make changes to said workbook. I want to have a "View Category Tree" button on the userform that, when clicked, will launch ANOTHER userform/window (MsgBox is too simple) that displays an outline of the master/sub categories with their questions. Example:
Code:
Excel Basics
     Menu Structure
          File
          Edit
          View
          Insert
          etc.
     Cell Formatting
          Number
          Alignment
          Font/Border/Patterns
          Protection
Beginning VBA
     Recorded Macros
          Highlighting
          Sorting/Filtering
     Editing Recorded Macros
          Filtering for current cell value

I want to put this in an unchangeable textbox with a scroller on a window that pops up when I click "View Category Tree". How do I do this? Can I do it with a MsgBox? Do I need to insert another UserForm in my workbook, or can I create it on the fly?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I think it would make the most sense to create another Userform. MsgBoxs aren't good for any kind of functionality except a message and a button. If it were in a Userform you could include a locked Textbox as well as a scroll bar and any additionally functionality you may later want.
 
Upvote 0
Thank you BusinessAnalyst! :) Now I've got a fun challenge to bold and italicize specific parts of the textbox. Found the Characters() method, but can't find a way to return the textbox as a range! Will post new thread.
 
Upvote 0
Thank you BusinessAnalyst! :) Now I've got a fun challenge to bold and italicize specific parts of the textbox. Found the Characters() method, but can't find a way to return the textbox as a range! Will post new thread.

Perhaps return the textbox value as a seperate string variable, then call that within the Characters() method. Otherwise you could always send the textbox value to a cell in a hidden worksheet, then manipulate that cell as a range.
 
Upvote 0
Here's what I have so far that's not working due to the Characters() needing an object (I'm guessing a Range object)

Code:
Sub showCategoryTree()
    Dim currentRow As Integer
    currentRow = 10
    frmCategoryViewer.txtCategoryViewer.Value = ""
    Do While Intersect(Worksheets(1).Range("A" & currentRow), Worksheets(1).Range("Comments")) Is Nothing
        If Not Intersect(Range("MasterCategories"), Range("A" & currentRow)) Is Nothing Then
            frmCategoryViewer.txtCategoryViewer.Value = frmCategoryViewer.txtCategoryViewer.Value _
                & Range("A" & currentRow).Value
            frmCategoryViewer.txtCategoryViewer.Value.Characters(Len(frmCategoryViewer.txtCategoryViewer.Value) _
                - Len(Range("A" & currentRow).Value), Len(Range("A" & currentRow).Value)).Font.Bold = True
            frmCategoryViewer.txtCategoryViewer.Value = frmCategoryViewer.txtCategoryViewer.Value & vbCrLf
        ElseIf Not Intersect(Range("A" & currentRow), Range("SubCategories")) Is Nothing Then
            frmCategoryViewer.txtCategoryViewer.Value = frmCategoryViewer.txtCategoryViewer.Value _
                & Chr(9) & Range("A" & currentRow).Value
            frmCategoryViewer.txtCategoryViewer.Value.Characters(Len(frmCategoryViewer.txtCategoryViewer.Value) _
                - Len(Range("A" & currentRow).Value), Len(Range("A" & currentRow).Value)).Font.Italic = True
            frmCategoryViewer.txtCategoryViewer.Value = frmCategoryViewer.txtCategoryViewer.Value & vbCrLf
        ElseIf Not Intersect(Range("A" & currentRow), Range("Questions")) Is Nothing Then
            frmCategoryViewer.txtCategoryViewer.Value = frmCategoryViewer.txtCategoryViewer.Value _
                & Chr(9) & Chr(9) & Range("A" & currentRow).Value
            frmCategoryViewer.txtCategoryViewer.Value = frmCategoryViewer.txtCategoryViewer.Value & vbCrLf
        End If
        currentRow = currentRow + 1
    Loop
    Me.Hide
    Load frmCategoryViewer
    frmCategoryViewer.Show
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,924
Members
448,533
Latest member
thietbibeboiwasaco

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