Choosing Parent Selection From Listbox And Have It Automatically Select Children Selections

Apr 22, 2013

I have a listbox with a state and below it several cities. For example:

New York
New York - New York City
New York - Nassau County
New York - Westchester
New Jersey
New Jersey - Newark
New Jersey - Monroe County
New Jersey - Passaic

I would like to select the state and have it auto select all of the related cities including the state. So if I select New York,

It would look like this, where all are highlighted (as if selected). I coudln't find the highlighter on the thread tool bar:

New York
New York - New York City
New York - Nassau County
New York - Westchester

View 9 Replies


ADVERTISEMENT

Choose Parent And Return List Of Bottom Level Children?

Apr 16, 2014

I have a large flat hierarchy table. I am looking for a method to select a parent and return a list of my lowest level children. I am somewhat familiar with VBA but I don't know where to begin coding this.

This has been a great learning source over the years, but this is one of the few instances I cannot find my problem so I am now posting. Example below:

Child
Parent

4
5

3
4

2
3

1
5

40
50

30
40

20
30

10
50

22
100

If I select 5, I want values 2 & 1 returned.
If I select 50, I want values 20 & 10 returned.
If I select 100, the value 100 should return.
If I select 40, the value 20 should return.

View 6 Replies View Related

Save Listbox Selection And Repopulate Selections When Opening Workbook?

Apr 15, 2014

I have a workbook that has 2 worksheets (Sheet1 and Sheet2). Each sheet has 2 checkboxes and a listbox that has 6 columns. Everything works great until I save and close the workbook. When I reopen, all the selections for the listboxes are gone, however the checkboxes are checked as expected. Why aren't the listbox selections being saved? How do I get them to save? I found something similar in a previous post but it referred to a userform which I am not using.

View 6 Replies View Related

Multi-Select Listbox Selections To Different Columns

Feb 11, 2014

I am currently setting up a userform where one of the options is for an error code (chosen from a listbox) but the user has to be able to select multiple codes. I have the below working if it is NOT multi select, works a dream and goes in the right column.

VB:
If ListBox2.Text = "A1" Then
LastRow.Offset(1, 20).Value = "x"
ElseIf ListBox2.Text = "A2" Then
LastRow.Offset(1, 21).Value = "x"

But as soon as I set it to mutliselect and choose say A1 and A2 neither one writes, I imagine because Listbox2.text is now A1,A2 and not just one or the other.

View 9 Replies View Related

Reloading Selections In Multi Select Listbox Control

Sep 28, 2006

I have a multiselect listbox in a worksheet that the user can select from. When the file is saved, closed and reopened, the user selections disappear. Is there a way of reloading the previous selections when the file is reopened? I have used the listbox from the control toolbox and have Excel 2003. My VB experience is very limited!!

View 8 Replies View Related

Add Msgbox With No Selection Error To Multi-Select Listbox

May 20, 2014

I want to add a msgbox with a no selection error to a multi select listbox I have. For a dropdown I just use "if .ListIndex =-1" but listindex doesn't seem to work. I'm playing with .selectedindex but it's not playing ball

View 4 Replies View Related

CheckBox To Automatically Get Checked If A Selection Is Made In The Listbox

Oct 14, 2008

I have a userform with a CheckBox and a ListBox. Is there a way to have the CheckBox to automatically get checked if a selection is made in the listbox?

View 9 Replies View Related

Selection On Multi-Select Listbox - Copy And Paste That Field From Any Folder

Aug 14, 2014

I am working on a macro, which asks the required field from multi select list box.

User can select required field, for example some user may be interested in
Region ID, Circle, BSC ID, Cell ID, Sector ID, City/Town.

Some user may be interested in Circle, BSC ID, Cell ID, Sector ID, City/Town.

Some user may be interested in BSC ID, Cell ID, Sector ID.

In sort, Selection on a multi select list box copy and paste that field from any folder.

That folder may have any location, and contains file which have.

Date
Vendor

Region ID
Circle

BSC ID

[Code] .....

View 1 Replies View Related

Fill Data Automatically After Choosing Name

Aug 14, 2008

I'm trying to create an invoice with customer list, and the problem now is I'm trying to find a list-dependent data way to input my customer's address.

At the moment, all I can do is a dependent dropdowns from a sorted list (see method here). So it's kinda troublesome in such that my list (of customers) opens up a list for address that has only one option (since there's only one address for each customer).

I hope there's a method out there whereby I can have a list of customers, then select the customer I want, and the address of this particular customer will appear in another cell below automatically (without the need of selecting it in another list).

My address is actually split into three different cells - Address, Building & Postal Code.

View 3 Replies View Related

Listbox Selections

Apr 19, 2006

I have a userform with multiple buttons and a listbox. When any button is clicked on, a listbox is created. The user selects various items on the listbox. Then the user clicks another button and selects other items based on a new list. If user goes back to click the original button, the original list shows up, but the selected items are not highlighted. Is there any way to keep those original selections highlighted (selected)?

View 9 Replies View Related

Listbox Multiselect Selections

May 2, 2006

On a multiselect listbox, is there any way the user can select a "block" of selections, instead of having to select them one by one? The list box I have has about 100 choices and it would be possible to select blocks of choices at a time. This is similiar to MS Outlook email where you can push the shift key to isolate a block of emails to move to a different folder.

View 2 Replies View Related

Remembering Listbox Selections

Jul 31, 2006

I have a workbook with 3 listboxes: Listbox1, Listbox2 and Listbox3. Selecting an item in Listbox1 will query a database which populates a hidden worksheet. Listbox2 then populates itself by drawing on entries in the hidden worksheet. Selecting an item in Listbox2 populates Listbox3 in the same way.

At the moment I have the spreadsheet so that nothing is cleared when I close or open the workbook, allowing the listboxes to remember what they were populated with when I closed the workbook. However, the listboxes will not remember what was selected when I closed it. Is this something which I can easily fix with a listbox property? If not, what is the easiest way for each listbox to remember what was selected when I closed it?

View 6 Replies View Related

ListBox: Allow Multiple Selections

Oct 9, 2006

I'm trying to see if it's possible to create a list box where I can select multiple values. For example, if a create a list box with the alues, "ant", "dog", and "cat". Is it possible for me to give the user the option to choose, "ant" and "cat"?

View 2 Replies View Related

Uncheck ListBox Selections

Dec 13, 2006

I have a form with 3 checkboxes. When any of the 3 checkboxes are checked, a set number of items are selected from a listbox. If a checkbox is checked, and then a new checkbox is checked, the listbox selection is cleared and selected with the new values from the new checkbox.

Problem: How can I code this so that if I check a checkbox and then deselect that same checkbox, my selected listbox items are cleared? Only when I select a different checkbox are they then cleared and repopulated.

Private Sub CheckBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim lngitem As Long
For lngitem = 0 To ListBox1.ListCount - 1
ListBox1.Selected(lngitem) = False
Next
CheckBox1.Value = False
End Sub..............................

View 2 Replies View Related

Listbox Selections Into Worksheet

Jun 21, 2007

Here is what I'm trying to create: I've put a command button on my worksheet that pops up a user form with a list box, an "insert" command button, and a "close" command button. I want to allow a user to make multiple selections in the list box, click the "insert" button, and have the selections inserted into the worksheet at a specific cell and fill down. I'd also like for it to allow the user to re-open the user form and add to the list after closing it.

I've hap-hazardly set up the list box for multi-select, but I'd like to see how it's "supposed" to be done! Also, as it stands, my list box selections will populate any cell that happens to be active at the time the initial command button is clicked. I've searched this forum and found that folks have posted similar questions. Those who replied posted a link, which I tried to follow but the page that followed could not find the file.

View 5 Replies View Related

MultiSelect Listbox Selections To Cells

Jul 23, 2009

I have a MultiSelect Listbox with two columns of data and I want to enter the listbox row data into different cells of a sheet. For example, the selected listbox first column data to be entered to Sheet1, activecell and rows below (for other multiple selections), and the selected listbox second column data to be entered to Sheet1, activecell(0, 2) and rows below (for multiple selections).

View 2 Replies View Related

Storing ListBox Mulitselect Selections

Nov 30, 2006

I am writing a macro that allows a user to select which fields they would like to copy from over 100 workbooks. I am using a multiselect ListBox on a userform that I populate using the "additem" approach. There are around 20 fields for the user to choose and each represents a column in the worksheet (all 100 worksheet are in the same format).

I need to use the user selection to identify which columns to pull from all worksheets.

How can I identify the selection the user made and incorrporate that in a copy range type of code. I planned to "Unload" the form after the user hit the "Run" (command) button (not sure if this will matter).

View 9 Replies View Related

MultiSelect Listbox: Counting Selections

Aug 31, 2006

I've got multiselect option 2 enabled: fmMultiSelectExtended and I want to be able to count up the total number of rows the user has selected.

View 9 Replies View Related

Keeping Listbox Selections After Calculation

Mar 17, 2007

I have been using VBA for 2 weeks and have run into a problem I can't find an answer to from searching various sites. I have a listbox with two columns (one name, one numbers). I have two buttons, one that puts the selections onto a sheet and then calculates the associated numbers and then updates a label with the sum of the selections. If they accept the selections, they can then press submit to record the data in the sheet. My problem is that after they press the calculate sum button the selections on the list dissapear, I need them to remain as they may need to change them based on the sum amount. How can I get the listbox to get the sum as necessary (and display within the userform), but not lose the selections in the process.

View 7 Replies View Related

Multi-Selection List Box Selections

Feb 13, 2008

I created a userform for budgets. Currently the way that the user selects the year for a particular line item is a combobox. The combobox is filled from a textbox, where the user inputs the project duration. For example if the user put five years into the textbox, the combobox would have years 1,2,3,4,5, and a default of all years. I want to change the combobox to a multi-selection List Box. I changed the sub that loads the current combobox to this:

Public Sub ComboLoad(cboExpense As ComboBox, cboJob As ComboBox, _
ltAp As MSForms. ListBox)
Dim i As Integer
ltAp.Clear
If Len(UserForm2.txtYears) = 0 Or Len(UserForm2.txtYears) = "" Then
ltAp.AddItem ("All Years")
Else
For i = 1 To UserForm2.txtYears
ltAp.AddItem i
Next i
ltAp.AddItem ("All Years")
End If
ltAp.Text = "All Years"
'ltAp.value = "All Years"

I used to be able to select a value for the combobox, (the default of all years), but I get an error if I include that part of the code now. I wanted to know how I can make this selection by code. Also, the bigger question for me is how do I deal with multiple selections that may or may not be sequential. As an example, for the travel section, there may be a particular expense that will occur in yrs. 1,3,5. I found some info about referring to the position in the array, but it seems like this will constantly change. I could imagine doing case scenarios, but it seems like there would be too many potential possibilities to cover.

View 5 Replies View Related

Autofilter Data Based On Listbox Selections

Jan 7, 2013

Iam trying to auto filter a data range based on criteria passed from a list box selections.I want the auto filter to be filtering column 2 of the data range based on ALL the items SELECTED from a multi-select list box (named listbox2) at the click of a button. Here is what i currently have:

VB:

Sub Cmd1_Click()
Application.ScreenUpdating = False
For i = 0 To ListBox2.ListCount - 1
If Me.ListBox2.Selected(i) Then
Range("A3:C600").AutoFilter Field:=2, Criteria1:=ListBox2.List(i), Operator:=xlFilterValues

[Code]...

It works, only that it filters the data by ONLY the last selected value of the list(i.e only one value item in the list). I want it to loop through ALL the selections, applying filter on column 2 based on EACH of the selections on the list box.

View 9 Replies View Related

Multiple Selections From Listbox To A Single Cell?

Aug 9, 2013

how do I save multiple items selected from a userform listbox to a single cell on a worksheets? How do I have those values display in a listbox on a userform for editing data sets?

View 2 Replies View Related

Populate Array From Mutiple Listbox Selections

Aug 26, 2006

Trying to load an array from user selected items in a listbox

My code returns Type Mismatch error

I don't know why as a I did not declare type for the array I thought treated as variant so should accept any values?

Debug:

arrSelected(intI) = .Selected(intI)

Private Sub btnOK_Click()
Dim arrSelected
Dim intI As Integer
With Me.lstAccounts
For intI = 0 To .ListCount - 1
If .Selected(intI) Then
arrSelected(intI) = .Selected(intI)
End If
Next intI
End With

View 3 Replies View Related

Creating Range Of Listbox Based On Selection Made In Another ListBox

May 1, 2014

I have two lists mainly TV Brand & There Models.

List 1 (TV Brand)
Sony
LG
Samsung
Depended List 2 (Models)
Sony LG Samsung
EX420 55EB9600 PL43E450A1FXZP
EX430 77EC9800 PL43E490B4FXZP
EX550 55EA8800 PL43E400U1FXZP
EX520 KN55S9C UN32EH5300FXZP
EX645 55EA9800 PL64E8000GFXZP

I'm using two Listboxes (Form Control) with multiple selection options namely Listbox 1 (Brand) & Listbox 2 (Models). I want listbox 2 input range to be depended on selection made on Listbox 1 (Brand). For example, if user selects Sony then box2 should show only Sony's models and if user selects Sony & LG, box2 should show models for both Sony & LG.

View 3 Replies View Related

Extracting Multiple Selections From Multi Column Listbox

Apr 1, 2014

I have a multi selection listbox that has 6 columns located on the "Form" worksheet. Trying to extract the data from the selected lines (and all columns for the selected line) and copy to another worksheet (ExtractedData). My code so far only works to extract the multiple selections for the first column. Not sure how to have it include all columns. Ideally would like to have the six columns to be extracted and placed in separate cells on the ExtractedData worksheet. Here is what I have so far:

Sheets("Form").Select
SelCnt = 0
With Worksheets("Form").ListBox3
For i = 0 To .ListCount - 1
If .Selected(i) Then
SelCnt = SelCnt + 1

[Code] .......

View 3 Replies View Related

Excel 2007 :: Write Selections From Listbox To Cell?

Oct 9, 2011

When I attempt to extrapolate and modify the code I get nothing but error messages. I've also looked through my two Excel 2007 books (each of them 1,000+ pages long) and there is no mention of this subject anywhere.

I am running Excel 2007. I have a multiselect listbox in a worksheet (not a user form). I want a user to be to be able to select multiple items from that listbox and when the the user moves out of the listbox (i.e., when the focus is no longer on the listbox), I want the selections to be copied into a cell on the same worksheet with each of the selections separated by a comma.

So for example, if the listbox (named "ListBox1") contained the following items...

North
East
South
West

...and the user selected both "North" and "West" from the listbox, the following text would get automatically written into cell A2 in the same worksheet after the user move outside of the listbox...

North, West

I know enough VBA to be dangerous (usually just tweaking code written by the macro recorder), but this one is eluding me. My two questions are:

1. What is the VBA code required to give me the result I'm looking for?
2. How would that code be called/where does it reside in the workbook? For example would I put the code in a macro and associate that macro to the listbox object??

View 6 Replies View Related

Show/Display Selections In MultiSelect ListBox Control

Sep 26, 2006

Ive made a worksheet with a userform and ListBox. The listbox is filled with names. If you click on the last button a msgbox with your selected names is displayed. If you select the button without a selection from the listbox a message pop ups to warn that no selection is made. If you select any name afterwards and click on the button the message still pops up unless you select the first entry from the list ("natalie") then the code is right executed. I'm struggeling with the code for several days. I wonder if by any change somebody wants to correct the code. (I've uploaded my sheet)

View 2 Replies View Related

Userform Listbox That Lists Data Based On Radio Button Selections

Mar 14, 2009

I have a worksheet (attached) that lists various clients in columan C. Column E lists whether each of the clients listed in Column C are 'Existing Business' or 'New Business'. I require a user form that has three radio buttons (one to select 'New Business', another for 'Existing Business' & one for 'All').

When Selecting a radio button, (e.g. 'Existing Business'), I need all clients listed in Column C of the worksheet that also have 'Existing Business' in Column E to be listed in a ListBox on the UserForm (with the second radio button allowing the text box to list 'New Business' and the third to list both Existing and New).

View 3 Replies View Related

Disable Selection In Listbox On Selection Of Item

Apr 4, 2013

I am working on a project where user has to select an item from a listbox, however there is a condition that if user select an item, other items of listbox should be disabled so that he/she can not select any other item.

Is there any way to do that as I tried

VB : Listbox.enabled = False
and
VB : Listbox.locket = True

in Listbox - Click/Change but no desirable results got.

View 1 Replies View Related

Select Multiple Rows As Separate Selections

Jul 27, 2006

Is there a way (with a macro?) to select all rows within a certain range (e.g. from row 3 to the end of the sheet) SEPARATELY, just as selecting them manually with ctrl+select?

Like in my example sheet;
I would use the AutoFilter on row 2 to show only the items with prices equal to 30. Now I want to select the entire rows (name, amount & price) of these two items, so that when I turn of the AutoFilter the two rows would still remain selected.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved