Use case: There is a list of checkboxes with some of them are checked. I have to iterate over the checkboxes (all checkboxes are with same x-path) and have to check that are not checked. I am using while loop for iteration with condition "while element[x-path] is visible on the page". Followed by a If condition to check the box
Problem : In TestSigma The loop iterates only upto the first unchecked checkbox and checks it and stops iterating others. Help me on this issue.
Related
i did a VBA macro to populate the Webform as below before assigning more code from Excel
But before i can proceed, I am on hit block
this is the code that i use
When i try to click on F5, i cannot manage to input any value on the search button.
what did i do wrong here.
enter image description here
getelementsbyclassname returns a collection of elements which were matched, not a single element, so you need to use (0) to indicate you want to work with the first element in that collection (assuming there was at least one match found) Eg:
IE.document.getElementsbyClassName("blah")(0).click
Really simple question but just can't find an answer anywhere.
I've created a command button that removes items from a list in a combobox based on which item they have selected. When the last item is removed, it "technically" is removed but the text for the last item remains in the combobox field. This would confuse the user; in this instance they would believe an item is still attached (the list of items are file pathways.)
I've tried convoluted routes e.g. setting the first index field as "No attachments" and building a solution around this. e.g. when the last field is removed, set it to "no attachments." but this requires me to initialise the combobox this way and change other areas of my code which just unnecessarily complicates it all.
Just a brief description of code, it takes a boolean which the user prompts by choosing either yes to removing all or pressing a remove selected option
Private Sub rmvFile(removeAll As Boolean)
If removeAll = False Then
'trying to work out how to remove selected item
fileListComboBox.RemoveItem (fileListComboBox.ListIndex)
Else
Do While fileListComboBox.ListCount > 0
fileListComboBox.RemoveItem (0)
Loop
End If
End Sub
The result I would expect is that when I remove the last item in the combobox it would be blank, but this doesn't happen. The last items text remains in the combobox, confusing the user.
is it possible to create listbox with multiple checkboxes in one row (Excel VBA)?
Thanks
Kamil
I'm not sure I understood your question fully, but I'll elaborate on ListBoxes as much as I can.
First things first: Checkboxes and ListBoxes are different objects in Excel Userforms. The first is the little box that returns a "true/false". The second is a list of items which can be chosen. Clicking in a Checkbox will make the tick mark appear/disappear (or fade if tristate is enabled), while clicking a Listbox row will turn the listbox row "blue"/"white" (or whatever color is being used for the selected rows). In both elements, clicking is a way to toggle between True and False.
While a checkbox only allows for a single information to be marked as True or False, a Listbox allows you to select entries out of a list. That list may be inserted through code (.AddItem method) or passed from a range (.RowSource property)
ListBox objects allow for multiple columns of data to be attributed to one row element, but each row is an entire element (which means you cannot pick the element on row 3, column 2 - only all of row 3). The number of columns is established using the ColumnCount property.
By changing the value of the MultiSelect property, you'll allow the user to select multiple or single row elements simultaneously on your Listbox. Using the Selected( RowIndex ) property, you can check whether or not an item is currently selected (returns True/False). Remember that row indexes start at 0.
Finally, if you're using the MultiSelect property set to fmMultiSelectSingle and have a single column (as far as I know), the Text property can be used to return the selected item's value.
An easy example of a listbox is in Excel can be found at File > Options > Customize Ribbon (or something like that). There are two listboxes, one (on the left) with the visible items and another with the available items. A pair of command buttons is used to move items between boxes. That's a simple application you can likely find already setup online.
Am I on track to answer your question?
Listbox 1 contains names of hairdressers and Listbox 2 contains services provided by all of them then in Listbox 3 both the selected hairdresser(only 1 allowed) and and selected services are contained. There is a remove button which removes items from Listbox 3. I want a code for the button that if a hairdresser is removed all services also get removed otherwise only services are removed.
For Each str As String In Hairdresser.lstHairdresser.Items
If Not lstHairdresserAndServices.Items.Contains(str) Then
lstHairdresserAndServices.Items.Clear()
Else
'more code here but above statement never gets true
End If
Next
If the hairdresser is always the first item in the 3rd listbox, all you have to do is check if the selectedindex equals 0. If so, clear the listbox. Otherwise just remove the selected item.
Alternatively, you could search the the 1st listbox for the selected string. If found clear the listbox otherwise remove the selected item.
It is also possible to mark the listbox items when you add then to the listbox. Set the tag property to something like "hairdresser" or "service" and when the remove button is clicked all you have to do is check the tag property.
Finally I would recommend a different approach: Instead of adding the items to the listbox, fill a data structure with the hairdresser's name and services, display this structure in the listbox and when the remove button is clicked compare the selected item to the structure to find out what was selected.
I am populating a listbox with a large list. The user then has the option of choosing multiple items from this list. I then want to perfrom a few actions on only the selected items.
I cant figure out how to only perform the actions on only the highlighted selections.
'I have tried all combinations of
For each Listbx.SelectedItems.ToString in ListBx.Items.ToString
For each Listbx.SelectedItem in Listbx.Items
'etc, etc
''Performing actions here but it is still doing it with all entries
Next
For Each selecteditem As [Object] In Listbx.SelectedItems
//Your code on each item
Next