Listbox Value

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,060
I would like a listbox to list the following text but do not know how to do it, can someone please help.

Row 1 in the listbox would be the word - Help File
Row 2 in the listbox would be the word - Log File

I want it to have many other words but if someone gets me started I can manipulate the rest.

I want it to contain text so that when I click my activate button it will run macros based on the text that I have selected.

thanks
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
I would like a listbox to list the following text but do not know how to do it, can someone please help.

Row 1 in the listbox would be the word - Help File
Row 2 in the listbox would be the word - Log File

I want it to have many other words but if someone gets me started I can manipulate the rest.

I want it to contain text so that when I click my activate button it will run macros based on the text that I have selected.

thanks
Are Help File and Log File Macro names ? If so they shouldn't contain an empty space.
 
Upvote 0
easiest way is to put all texts you need in a cell range somewhere. Then in the ListBox Properties Window put this range in the RowSource property - something like:
=Sheet1!A1:A10
 
Upvote 0
Thanks.
The help and log files are names and you are right they would actually be set up as Help_File and Log_File, I do not want to paste the data into the sheet as it is a large sheet and I don't want to have to insert sheets and then delete them later.

Surely there must be a way you can type the names into the script yourself like a textbox or label etc...
 
Upvote 0
Thanks.
The help and log files are names and you are right they would actually be set up as Help_File and Log_File, I do not want to paste the data into the sheet as it is a large sheet and I don't want to have to insert sheets and then delete them later.

Surely there must be a way you can type the names into the script yourself like a textbox or label etc...
You can create a "Control" where it contains all sorts of control data for u

In this case, it will contain all the Items that you wan to include in the ListBox. So if in future, u dont wan certain items, just go to Control and delete the line.
 
Upvote 0
Hi Zyel,

How do I create the control and would I be able to click on one of the names such as Help_File and have it run a macro.
 
Upvote 0
Add a ListBox to Sheet1 and put the following in the Workbook module :

Workbook example.

Code:
Option Explicit
 
Private WithEvents oCmbtn As CommandButton
 
Private Sub Workbook_Open()
 
    With Sheet1.ListBox1
        .Clear
        .AddItem "Help_File"
        .AddItem "Log_File"
        Set oCmbtn = .Parent.CommandButton1
    End With
    
End Sub
 
Private Sub oCmbtn_Click()
 
    With Sheet1.ListBox1
        If .ListIndex = -1 Then
            MsgBox "Select A Macro Name first"
        Else
            Application.Run Me.CodeName & "." & .Text
        End If
    End With
    
End Sub

Private Sub Help_File()
 
    MsgBox "Macro 'Help_File' running"
 
End Sub
 
Private Sub Log_File()
 
    MsgBox "Macro 'Log_File' running"
 
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,447
Members
448,966
Latest member
DannyC96

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