i have a form control listbox (list box 5), it is multi select, i need to create a for next statement that loops through the list in and tells me which "row numbers" as it were are selected. i.e if the 1st and 3rd ones are blue, it returns 1,3 in a cell? (lets say cell A1).
I'm writing a audit trail that when the user changes a cell in a specified column the reason for the change gets recorded in a different sheet. If however the list box is cancelled then the cell should not change.
The code should do the following:call listbox when cell value change user selects one or more reasons from list if nothing selected then prompt for selection record username, date, cell value and reasons if click cancel then undo change, i.e. don't allow user to change the cell without selecting a reason Steps 1-4 works well Step5: cancel undo the cell change, but doesn't unlaod the form and hence the load-unload goes into a loop.
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column = 15 Then Call Launch(Target) End If End Sub Module
Global reasons As String Sub Launch(tRange As Range) Dim prodId As String...............
I'm playing with simple UserForms to get the hang of VBA. I was trying an example for the help files (Using xl2K), and this isn't working. My first challenge was figuring out that I needed to 'create' a UserForm to begin with.
I have a userform running with a number of text boxes, as well as one listbox. To extract a value from a text box I obviously write something = me.textbox.value. How do I do the same for a listbox (single item) as me.listbox.value produces an error!
I have a listbox control on a User Form. The properties are set as follows: MultiSelect: 1-fmMultiSelectMulti; ListStyle: 1-fmListStyleOption. With these properties the user selects multiple items from the listbox by clicking checkboxes that appear to the left of each option. Once items are selected the user clicks a command button on the User Form and the selected items are placed in a single cell on an excel worksheet. The excel worksheet contains an excel list of records. The records on the worksheet can be edited or added.
Letís focus only on the MultiSelect listbox. A single item is selected from the listbox and is applied to cell G2 as CRUSHING. On the next record two options were selected. These items were added to cell G3 as CRUSHING; SHEAR. The next record had three items added to cell G4 as SHEAR; LATERAL BENDING; FLEXION. As you can see from the above example multiple items are added with the item name followed by a semicolon space and then the next item name. The user form contains command Buttons that allow the user to move to the NEXT, PREV, FIRST, LAST, ADD, and EDIT records.
Here is my problem: I can check multiple items and have them added to a single cell of the current record on the worksheet. My problem is how to reverse this process. I need to move back to a previous record and have the User Form appear with the check boxes of the currently selected record.
I have created a user form with a multiselect listbox. The user form displays a checkbox to the left of each ListBox item that can be selected. Once selected the user clicks the SAVE button on the user form and the results are stored in a single cell on an excel workbook. The user form contains several other buttons that allow the user to view the NEXT and PREV records stored on the excel worksheet. If a checkmark is placed next to the option Shear and the Save button clicked, the word Shear would be recorded in the 7th column, current row of the worksheet. If the user checks several boxes like: Flexion and Lateral Bending, the 7th column of that row would store Flexion; Lateral Bending. The macro inserts a semicolon space between multiple selected items.
When the user clicks the PREV or NEXT button on the user form to go an existing record I am having difficulty getting the correct checkboxes to be selected to reflect the contents of the 7th column, current row. The ListBox control is named GeneralInjuryMechanisms. The code that I currently have for this section of the macro is as follows:
Dim strInput As String, strOutput As String Dim varZz As Varient, i As Integer GeneralInjuryMechanisms.Clear 'Clear the existing ListBox options AddRegionalMechanisms 'Recreate ListBox options based on current record in column 7 strInput = Cells(r, 7).Value ' i.e. cell on worksheet with Flexion; Lateral Bending varZz = Split(strInput, "; ") 'create array of values using "; " as delimiter. For i = LBound(varZz) To UBound(varZz) ' loop through values...................
Allow a user to make multiple choices from a user form listbox populated from a named range (LIST), that when checked and the submit button is clicked would add TRUE to column A in the same row for each selected item. Then when the user opens the form again - for each row where there is TRUE in column A, the check box on the form would be checked and if the user then removed the check and clicked submit, TRUE would be removed from column A that was associated with that item/row on the worksheet.
Using the Roy Cox Database code http://www.excel-it.com/vba_examples.htm , I am trying to populate a user form when the user selects a list row. I don't know if this is important, but I have extended my list beyond 10 columns. The list appears in UserForm2, and it should populate UserForm1. UserForm1 is also available to fill in from scratch; the info pulled from UserForm2 is from a search.
Here is my problem:
UserForm1 does not populate with the current selection, but rather the previous selection. It will appear blank upon the first selection. If I close UserForm2 after getting a blank on Form1 and call UserForm1 from its own macro, I will also see that previous selection.
I have been able to create a userform that allows users to fill out a form without the need to navigate throught the excel spreadsheet form that has been created. to further refine this I am trying to use either a list box or Combobox to display specific items for certain cells, ie Travel Method (Air / Rail / Other), or Department (Projects / Finance / Engineering / Admin etc). I can create these in a spreadsheet without to much problem, but sofar have been unable to get them to work in the user form.
I'm putting together a spreadsheet to do with football betting, that involves calculating various stakes and odds and probabilities. I've done pretty well, but I want to take it to the next level.
At the moment, I have 4 sheets which are completely self contained:
sheet one = betting on 2 matches sheet two = betting on 3 matches etc
This was the easiest way to do things when I was learning.
Now I want to look at incorporating more flexibility into my spreadsheet. I want to investigate the possibilities of having a small form to be filled in, such as the following:
Number of matches to bet on... a drop down menu for the user to choose from
and then for the visible area of the sheet to change to show the appropriate layout for their selection. So they'd choose the number of matches they want to bet on, and the spreadsheet would display what they need automatically.
I've looked at putting forms in and think I could do that quite easily, but how can achieve the effect of changing the layout/visible area depending on the chosen option?
When I type in a ticker into TextBox2 the form is prepopulated. Sometimes the info that is prepopulated is incorrect and the user should just be able to click in the textboxes and make the changes. The problem is that when the user does click on the boxes and makes the changes and hits submit the combobox values do not change and stay that of the vLookup results. So, the vLookup results can't change even if the user makes the change and hits submit. What am I missing. Do I have to declare somehwere that ComboBox1.value (for instance) is actually the value as of the submit button ebing clicked and not when the vlookup happens?
Private Sub TextBox2_Change() On Error Resume Next TextBox1.Value = WorksheetFunction.VLookup(TextBox2.Value, Range("Data_Company_Names"), 2, False) ComboBox1.Value = WorksheetFunction.VLookup(TextBox2.Value, Range("Data_Company_Names"), 4, False) ComboBox8.Value = WorksheetFunction.VLookup(TextBox2.Value, Range("Data_Company_Names"), 3, False) ComboBox11.Value = WorksheetFunction.VLookup(TextBox2.Value, Range("Data_Company_Names"), 5, False) On Error Goto 0 End Sub
I set up a range of cells to show a form when they are double clicked. This form gives the user the choice to pick a color and text from a list. When the user clicks "OK" the form closes and changes the cell based on the user's input (i.e. Red, "N/A"). I want only the double cliked cell to change color and text.
Problem: My code runs fine, but I cannot find a way to let the form change the text of the cell. Only the color is changing. I have tried calling the cell out in the code, but I get an error. I cannot find a way to change the text in the cell.
Code: Private Sub CommandButton2_Click() Dim ColorChosen As String Dim WordChosen As String[code].....
I have some code for changing the scale of my chart axes so that when new data is inserted into the column which the chart sources from (say column B), the axis scales on my chart will automatically adjust (as the Excel algorithm sometimes leads to charts which are a bit squashed). This code works fine, and I have included it below.
I have then tried to introduce an ActiveX listbox so that when you select an item in the box, the reference number generated (1,2,3...etc) then determines which data series is inserted into column B using a vlookup function. However, when I do this, the original VBA code for automatically adjusting the chart axes no longer works.
Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) With ActiveSheet.ChartObjects(1).Chart
I have two listboxes on a worksheet and using VBA to load values into the listbox. I also have a combobox that is used to determine what values are to be displayed in the listboxes. I select a value from the dropdown list and depending on the value selected, a list gets populated in the listbox. This works just fine.
The problem I'm having is that when I adjust the zoom on the worksheet, 75% for example, the listbox automatically changes the width when new values are displayed. I try using the listbox1.width = xxx, to keep the width in place, but that doesn't really work.
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.
I can easily put a listbox into a spreadsheet and fill it with a rage of data from a sheet, however I am looking to create 2 listboxes where one will be filled with hidden spreadsheets within the workbook and the other with non hidden, to give the user the ability to move one from the other. The problem I am having is that I do not know how to call these created listboxes from in VBA. I can easily acheive this in useforms but would prefer it to be in the spreadsheet as I already have a number of userforms that fill data in a large number of spreadsheets that I want to hidden initially.
using VBA in excel. My questions is: I would like to make a listbox that has 1 column and shows all of the headers in my different worksheet columns, and I would like to hide the columns based on which ones are selected in the listbox, is this possible I am having trouble findings examples online.
Attempting to populate a listbox from a worksheet range at runtime As far as I can tell the code is correct But the listbox returns results from ws("Data") not from ws("WA")
Sub comp_bs_AnalyzeAccounts() Dim wbBook As Workbook Dim wsWA As Worksheet Dim rngWA As Range Dim lngRows As Long Set wbBook = ThisWorkbook Set wsWA = wbBook.Worksheets("WA") comp_bs_XTract lngRows = wsWA.Range("A65536").End(xlUp).Row Set rngWA = wsWA.Range("A1:A" & lngRows).................
I have a list of six digit codes and I want to use these to populate a listbox based on the selection of a value in an existing listbox.
I have managed the following code by osmosis from various places:
Private Sub ListBox1_Click()
Dim Cell As Range Dim Test As New Collection Dim Item Dim i As String
So what I'm trying (and failing) to do is add a clause that will increase i by one, add that to the collection "Test" and then add one again etc., etc.; until it reaches the maximum value for i in the list - in this case 187410 - but some codes run into the 20s. Other cases will give a different value for i.