I have a listbox with 8 columns. Multiselect is enabled, and it must stay this way. As part of my program, after the user presses a command button, I need to use the row indexes of the selected rows in order to copy the selected information into an array which is then placed in a different listbox, and then delete the items from the original list. Pseudocode of what I want to do:
But my understanding is that .ListIndex does not work this way with multiselect listboxes. I've tried searching for a solution for a while, but I cannot find one.
I have a multiselect listbox with values that gets populated from a sql statement, and I would like to get is the first or second index from the selected item. I know how to get the listindex from a combobox by using:
VB: cbnumber.List(.ListIndex, 0)
How can I loop through and get the 1st index number for the selected items only from the listbox? I want to pass this index number to another sql statement.
I have a mulit-extended listbox, a textbox and a button on a form.
I have populated the listbox with a list of files from a directory no problems.
First Part (Single Selection):
When I click on one/single filename in the list I want:
1. The textbox to be populated with the name I have selected
2. When I click the button (With the single filename selected, I want to call a function passing the filename I have selected.
The function could contain a msgbox(selecteditemname) for now.
Second Part (Multi Selection):
When I multi select filenames from the list I want:
1. The textbox to be populated with "Multiple Files Selected"
2. When I click the same button as before (With multiple filenames selected, I want to call a different function and pass each filename individually in may be a for loop)
The function could contain the loop and with each filename in the loop msgbox(selecteditemname)
I have tried the above and noticed that the listbox1.value property for multi listboxes dont seem to work and I am not really sure how to distinguish between one selection or multiselection to get a button to pass off to two separate functions.
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.
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
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!!
I am trying to create a data entry form with a text field and a listbox. The list box is populated by another sheet and the text box will be used to enter names. I need to be able to enter a new name, select multiple options from the list box and then click a button to add this info to a sheet in excel.
I have read about changing the list options to allow this etc - the problem is I can't get the results to go back into excel - all I get is a name with nothing from the listbox.
changing two variables a various amount of times and running the same procedure and copying the resutls into another sheet. Seems like a perfect place for a macro. However, these variables can be chosen from a list that the user wants. So why not build in a listbox for each one. Now I have two listboxes one for variable A and one for variable B.
The procedure in theory goes something like this we change variable A from the base case and then run the procedure for variable B, get the results, then run the scenario again but changing only variable B abnd repeat. Then once, all of the variable B scenarios are done, I want to change the variable A and then repeat and so forth.
That is the background and my main problem at this point, is that have these values in two listboxes, I know how to do the for each loops and such, however, I do not know how to do them for values in the listbox.
How do I identify the values selected in the respective listboxes and then pull them so I only use them for the for each loop?
i'm having a problem with a script I have (script is below). What i'm doing is running a script that displays files in a certain folder, those files are then displayed on sheet1 column O and are linked so when they are clicked upon, the file will open. I also have a combo box with a input range of $O$O. That puts the values in column O in the combo box. Now here is a problem and request.
Problem first, when I select the file names from the combo box, they don't open the file, all it does is display the file name in combo box and that's it. how to I get it to open up the file? Now for a request, I have another sheet that is almost exactly as the one i described above. The only thing different I want is when someone clicks on a file name from the combo box, instead of it automatically linking to the file, I want them to click on a button to display the file.
Sub HyperlinkXLSFiles() ActiveSheet.Unprotect Dim lCount As Long Application. ScreenUpdating = False Application.DisplayAlerts = False Application.EnableEvents = False On Error Resume Next With Application.FileSearch .NewSearch 'Change path to suit .LookIn = "c:Sec" .FileType = msoFileTypeExcelWorkbooks ' .Filename = " Book*.xls"..................
I have written a VB-excel program after a lot of reading on this forum. Purpose of the program is to load a number of log-files with lots of data.
I load these files in a 2 column listbox, were the 1st column is the name of the file and the second column is a number, starting with 1, 2, 3 etc.
Since I don't get the files in the order I want them to be, I created a button to change the number in the 2nd column.
Now my problem: I need to sort the listbox according to the 2nd column. I have a routine that works ok, but whenever I make a mistake like duplicate numbers in the 2nd column, I lose all the data in the listbox and can start over again.
Dim listarray(20, 2) As Variant, Log_name As String, k, i, n, m, listnum, pos, remove_num
listnum = ListBox2.ListCount
For n = 0 To listnum - 1 pos = ListBox2.List(n, 1) - 1 Log_name = ListBox2.List(n, 0) listarray(pos, 0) = Log_name listarray(pos, 1) = pos + 1 Next n.................
However, i have come across a cell which displays the result of a reference to another cell (something simple like =b32). Normally I would just link to b32, however, the macro has to be applied to a large number of documents and in some cases text has been specifically entered, while in others the reference has been used. Is there any way of using VBA to display either the result of a formula (if there is one) or text if this is the case?
I have 2 userforms. UF1 and UF2. UF2 has a rowsource set to its Listbox. UF1 has a search function that searches the original sheet. Now I want to double click on an entry in UF1's Listbox and select the same entry in UF2's Listbox. I want to then work with that entry in UF2.
I do all of this to circumvent Excels restriction. I can't search in a rowsource Listbox, but any edits done to my new Listbox wouldn't be made to the Excel sheet.
2nd File Location: U:My Work FileName: 333.xls Worksheet Names: Pro _Ser1 Ser1 (A1) value= db Ser1 (B1) value=1
What I want is a master spreadsheet to 'suck up' data from all the Ser sheets within all Workbooks and populate the master spreadsheet with Column A =A1 Values from all the Workbook, Worksheets Column B=B1 Values from all the Workbook, Worksheets
I have a form with a list box on it, I want the listbox to display a number (1 through 20), the agents name, and a count of how many observations they have had. Unfortunately I have been unable to find an example of how to add multiple columns to a list box. I found the usual listbox1.list(x,x)= "whatever" type stuff but that doesn't seem to work right.
how to populate multiple columns including the headers, or point me to a site that explains it or has code examples?
Here is the data I want to put in the multicolumn listbox (the number and the agent name are from a worksheet, the deskside is a calculation sumproduct based on the 3 sheets that make up the quarter....
I have made the function below to return a variant multidimensional array. I pass the function an array of folder paths that I wish to search through looking at subfolders within that path where their name matches a search string that I pass to the function. eg., it will find a folder named "Catnap" if you pass the string searching for as "Cat*".
The size of the array it builds depends on how many folders it finds that match the search string and so needs to be built dynamically. Hence, I believe it builds a 2 dimensional array horizontally and I transpose it at the end of the function. In each element I put the folder name that was found in the first dimension and the path to that folder in its second dimension.
I have a 2 column listbox on a form that I set this array to. eg., Me.ListBox1.List = DirPaths("C:","Cat*",vbDirectory,100)
This works fine and shows a list of folder items found by folder and path in the two columns of the listbox if there is greater than 1 search found. However, when the search only finds 1 then the listbox shows the folder name with the folder path in row 2 of the list box. (See below).....
which is completed with CTRL+SHIFT+ENTER, and it works properly. However, I want to do the same for all lines following, where it will go to the next item matching that value. For instance: on my SALESMEN sheet, I have John Smith, Fred Johnson, and Mary Williams. Fred Johnson is considered inactive, which is represented in the SALESMEN sheet as an "X" in column H. Therefore, I want line 1 to show John Smith, and line 2 to show Mary Williams.
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
I have a Listbox (Listbox2) in column C. The listbox allows users to select multiple items (in this case it is countries). So the user could select 1 or 20 countries based on the previous criteria.
What I would ideally like is for the next column (column D) to automatically list the selected items without having to use a command button in the actualy cell. However, I could put a command button at the end to say "Confirm" which would then transfer the above into the relevant cells.
This is an excel file, and each row would works the same. Basically users are entering products for set up row by row, so the file could be 10 rows or 200.
Just to be clear, it would look a little like this:
Drop Down Listbox Column C Column D
Canada (Selected) Canada, USA South Africa USA (Selected)
Ive been having lots of trouble programing a multi column listbox to play ball. On the form there is 1 tree view and two listbox's. The object is to double click a list 1 item and have that go into the list 2.
Connected to the listbox2_dblClick.. Takes the selected list item and adds to columns 1 intergra value. This places a annoyance to me where listbox 2 is not fully populated (you will see ive fully populated the list during my own testing) and a item is selcted if double click on a blank part of the listbox it will increase the int value of the selected item. I though of populating the list with blanks (used "." as visual) so a cheek could be made on the double click item and if blank do nothing.....
i have several listbox with two columns in a userform in a sheet i have several columns whith values and i'm trying to put the values from the columns in the respective listbox. down is the code i wrote but is stressing with column command
Private Sub UserForm_Initialize() Dim contar, j, i As Double Sheets("Historico").Select contar = 0 For j = 1 To 15 linha = j For i = 3 To 65536
I have attached my Excel File with the userform I am trying to do. What I am trying to do is change the table in the listbox based on the selection of the combobox and then my selection in the listbox will pass the selected values to Range A1:C1.