I've got a simple GUI in TCL with treeview, idea is to read some folders and populate the treeview based on the contents of the folder.
I can create the structure for the treeview but I'm not sure how to get selected values when selected with mouse (single or multi-select).
Preference would be to have checkbox but reading up on the forum has made it clear that it is not possible with tree view.
I wonder if there any alternatives to checkbox?
Could I request some direction or advice on following:
get all items selected below "Some Label", see Image attached.
Or individually selected items e.g. A, B, XX, YY (see Image attached.)
I found it impossible adding Y scroll bar, could someone advice.
below is a snippet of the code.
set list0 {A B C D E F}
set list1 {XX YY}
ttk::treeview $tw.tv.tree -height 25 -columns "#0" -displaycolumns "#0" -selectmode extended
$tw.tv.tree heading #0 -text "Name" -anchor center
$tw.tv.tree column #0 -anchor e -minwidth 200 -width 300 -stretch 1
pack $tw.tv.tree
$tw.tv.tree insert {} end -id Title1 -text "Some Label "
foreach key0 [lsort $list0] {
puts "Key0: $key0"
$tw.tv.tree insert Title1 end -text $key0 -tags clickable
}
$tw.tv.tree insert {} end -id Title2 -text "Some Other Label"
foreach key1 [lsort $list1] {
puts "Key1: $key1"
$tw.tv.tree insert Title2 end -text $key1 -tags clickable
}
grid columnconfigure $tw.tv 2 -weight 1
grid rowconfigure $tw.tv 2 -weight 1
For selection I used one of the examples posted on a thread on this forum
set selection [$tw.tv.tree selection]
set text [$tw.tv.tree item $selection -text]
puts "$text"
Unfortunately this returns an empty string.
ps: the code shown is only for treeview which is one part of the GUI, shown only to identify rookie error.
Thanks in advance,
George
Related
Conditional Formatting - If a value in column A of sheet 1 appears twice in column b of sheet 2, highlight the cell in sheet 1
I've been messing with the indirect modifier to see if I can get this to work.
=COUNT(INDIRECT("'Order Confirmation'!B:B"),A1)
But this has currently just highlighted all the cells on sheet 1 column a. I have tried
=COUNT(INDIRECT("'Order Confirmation'!B:B"),A1>2)
=COUNT(INDIRECT("'Order Confirmation'!B:B"),A1=2)
and this has changed nothing. I would appreciate some assistance
if Sheet2 is like:
then Sheet1 will be like:
=FILTER(A1, COUNTIF(FILTER(INDIRECT("Sheet2!B:B"),
COUNTIF(INDIRECT("Sheet2!B:B"), INDIRECT("Sheet2!B:B"))>1), A1))
UPDATE:
=FILTER(A1, COUNTIF(FILTER(INDIRECT("'Order Confirmation'!B:B"),
COUNTIF(INDIRECT("'Order Confirmation'!B:B"),
INDIRECT("'Order Confirmation'!B:B"))>1), A1))
...as a custom formula because you have numbers in dataset not text
In Google Sheets, I have a spreadsheet list, which includes a cell (E1) that chooses a random number like so:
C | D | E
------+---+------------------
1 | | |=RANDBETWEEN(1,99)
I would like to make another cell show the text in column C, row of random number from E1. How can I accomplish this?
Try this to retrieve the value from column c,
=index(c:c, e1)
I am working on automating a business process using excel macros in VB and I have it all completed except for one part. I have an inventory sheet that I would like updated upon running the macro. What it would do is search an order file for part numbers, compare those part numbers with the inventory sheet, and then remove inventory quantities within the inventory sheet based on the values found within the order sheet. These are in two separate workbooks. Here is an example of how it looks:
Spreadsheet A - Order Sheet:
A B C
Part #: Description: Quantity
123456 Item 1 1
1234567 Item 2 1
12345678 Item 3 1
Spreadsheet B - Inventory Sheet:
A B C
Part #: Description: Quantity
123456 Item 1 580
1234567 Item 2 790
12345678 Item 3 578
So this program would subtract values in Spreadsheet B - Column C based on the values in Spreadsheet A - Column C and Column A
In the order sheet even if a customer orders multiple items it shows each purchase as a separate item, so this program would only need to remove quantities of one at a time.
I'm rather new to this type of Excel Automation so any input would be greatly appreciated. I've been looking into Vlookup but from what I understand it only looks for information and displays existing values.
If the idea is to remove the "Orders" from the "Inventory" every time you run a macro, the right thing to do should be, in words, for each line in "Orders", search the corresponding object into the inventory and subtract the quantity.
In code, it's as easy as in words:
For j = 2 To Sheets("Orders").Range("A2").End(xlDown).Row
For k = 2 To Sheets("Inventory").Range("A2").End(xlDown).Row
If Sheets("Orders").Range("A" & j).Value = Sheets("Inventory").Range("A" & k).Value Then '<-- when the object is found
Sheets("Inventory").Range("C" & k).Value = Sheets("Inventory").Range("C" & k).Value - Sheets("Orders").Range("C" & j).Value '<-- subtract order's value
Exit For '<-- you don't need to loop any further after having found the object
End If
Next k
Next j
Press alt+f11
right click project on left and insert a module.
type in the mane code pane:
Public Sub UpdateInventory
'place some code like
for n1=0 to 1000
for n2=0 to 100
InventoryItemCode= Sheets("Inventory").range("A1").offset(n1,0).value
OrderCode=Sheets("Orders").range("A1").offset(n2,0).value
If InventoryItemCode=OrderCode then
'etc....
End if
Next n2
NEXT n1
End sub
see google for troubleshooting
I am trying to create a data validation drop down cell that displays a list of values pulled from a much larger list, but only the ones where the lookup value meet certain requirements. This would be like the SUMIF function that only adds the values where the lookup value meet certain requirements. Here is an example of my list:
V F
Apples x
Bananas x
Tangerines x
Tomatoes x x
Broccoli x
Pears x
Kiwis x
Plums x
Water melon x
Squash x x
I want only the ones with an "x" in the first column to display in the drop down.
Tomatoes
Broccoli
Squash
Also the original list can't be sorted. I am fine with using macros if that would work. I am using Excel 2010.
If you want a range of valid entries without blanks to use as a list for data validation, I suggest something like:
=INDEX($A$2:$A$11,SMALL(IF($B$2:$B$11<>"",ROW($A$2:$A$11)-ROW($A$2)+1),ROWS(C$2:C2)))
entered with Ctrl+Shift+Enter
There is about 20 minutes of explanation at https://www.youtube.com/watch?v=6PcF04bTSOM.
Without using VBA, you could create a copy of the list that is filtered. You can then reference the cells in that copy when you use data validation.
For example, you could do the following steps for your example above:
Apply a filter to the list where only those showing an x in the first column are showing. Copy the filtered list, then paste to another spot on the worksheet. Turn off the filter on the list, so it returns to normal. Go to the cell that you want to add a validation drop down to, and select data validation. Select list, then reference the copied list.
Using VBA, you could use this as a starter. The key is the Range.Validation method, which is explained in detail here. This reads your list in column A, finding those with an "x" in column B, and puts that in a validation list in cell E1.
Dim myvalidation_list As String
Dim last_row As Long, current_row As Long
last_row = Cells(Rows.Count, "A").End(xlUp).Row
For current_row = 1 To last_row
If LCase(ActiveSheet.Cells(current_row, 2).Value) = "x" Then
'put in the delimiting "," if the list already has an entry
If myvalidation_list <> "" Then
myvalidation_list = myvalidation_list & ","
End If
'add to the validation list
myvalidation_list = myvalidation_list _
& ActiveSheet.Cells(current_row, 1).Value
End If
Next
With ActiveSheet.Range("E1").Validation
.Delete
.Add Type:=xlValidateList, Formula1:=myvalidation_list
End With
I need a help in VBScript or either in QTP for the below case.
For example:
I have nearly 40 items in the weblist. I have only one item in the Excel sheet that is one among the 40 in the weblist. If I run the script, the one in the Excel should be select in the weblist. How do I perform this? I tried many scenarios, but couldn't get it to work.
Below are some of the sample pieces of code I tried in QTP:
ocount=Browser("name:=brw").Page("title:=brw").WebList("htmlid:=tabContainerBrandSite_123&rtyoh").GetROProperty("items count")
msgbox ocount
var7=mySheet2.Cells(2,"C")
For k=2 to ocount
ocount2=Browser("name:=brw").Page("title:=brw").WebList("html id:=tabContainerBrandSite_123&rtyoh").GetItem(k)
msgbox ocount2
merchantName = DataTable("Merchant_Name","Global") 'an example if value is saved in global sheet
items_count = Browser("Sarit").Page("Sarit_2").WebList("txtVendorCode").GetROProperty("Items Count") 'This will get all the items from your weblist.
i = 1
Do
webListName = Browser("Sarit").Page("Sarit_2").WebList("txtVendorCode").GetItem(i)
'this will get first value from the web list
If merchantName = webListName Then 'comparing first value from your value from global sheet
Browser("Sarit").Page("Sarit_2").WebList("txtVendorCode").Select(i) 'selects that value
Exit do 'because it has found your only value from the local sheet, it exits
else
i = i + 1
End If
Loop While i <= items_count