VBA Combobox, choose item using 2nd column item - excel

I have a UserForm containing ComboBox and items added to it (2 columns). When adding data of invoice I have button to insert data from latest invoice - to save some time.
ComboBox shows user only 1st column items and saving data using 2nd column items. When I want to copy data from last invoice it shows me error using below code. Code tries to select item using 2nd column item.
Is it possible to select proper item in 1 column using 2nd column item?
kraj_dostawcy is ComboBox name
kraj_dostawcy.List(kraj_dostawcy.ListIndex, 1) = fak_path.Offset(-1, 5)

If you use the control's BoundColumn property to set the column containing the values you want returned from it, you can just assign the cell value to the Value of the combobox, not to its List property.

Related

Add the value taken from the user for predefined Command Button (ActiveX control) to range of a ActiveX ComboBox

I defined
a ActiveX ComboBox named "cmbPeymankar",
a Text Box (ActiveX control) called "txtNewPeymankar".
a Command Button (ActiveX control) called "Add".
I have a table named "Table1" in sheet "DATA" so that the first column of Table1 contains the names that should be displayed in the cmbPeymankar list and 10 items are already written in it.
I have three questions:
How to define the value of "ListFillRange" of cmbPeymankar so that the values of column 1 of Table1 are displayed in its list?
What command should I write for Add button to add the value taken from the user for txtNewPeymankar to the end of the column 1 of Table1?
The value of cmbPeymankar can be selected from its list. If the user wants to type its value, how can I write an error message if the entered value is not equal to any of the predefined items for cmbPeymankar (in column 1 of Table1)?

When a row is added to one sheet, automatically add a row to another sheet

For Example: If I add a row between rows 1 & 2 in Excel sheet 1 then how can I reflect this change automatically in sheet 2?
Sheet 1
Sheet 2
You can use VLOOKUP function for that. First column of your Spreadsheet 2 will show first column of Spreadsheet 1 , same for the 2nd column
This is your first sheet you can change content of A and B column however you want.
For the Second Sheet add following functions
Column A - =IFERROR(VLOOKUP(Sheet1!$A$1:$A$1000, Sheet1!$A$1:$B$1000, 1, false), "")
Column B - =IFERROR(VLOOKUP(Sheet1!$A$1:$A$1000, Sheet1!$A$1:$B$1000, 2, false), "")
Now all changes from Sheet 1 will be shown in Sheet 2
On a worksheet, make a list of your names and convert the list to a table by highlighting the header and the values, press CTRL+T, give your table a name. While you still have a cell in the table selected...
On the ribbon, select Data > Get & Transform > From Table
The Power Query editor will launch in a new window and you will see the table displayed. You now have a query table. Change the name of the query. When you change the name of the query in the query settings panel on the right, it will update the name of the query in the query navigation panel on the left.
Add an index column. Go to Add Column > Index Column > From 1.
Now you have a dynamic index column attached to the names column. Go to File > Close and Load To
The query editor window will close and the Load To dialogue box will be displayed. Select Table > New Worksheet, Load to Data Model > Load.
Your query table will now be displayed on a new worksheet in your workbook. You can change the formatting on the Design tab of the ribbon.
Now, any changes you make to the original table are synced, all you have to do is refresh (Data > Refresh, from the ribbon or by right-clicking on the query table).
Try it out. Add a new name to the bottom of the data table, then go to the query table, right-click > data > refresh.

Applescript + InDesign Selecting Body Rows In Table

I am currently trying to automate some data formatting. The source data is formatted in Excel. The inDesign template is already formatted. I can right click the table and select body rows then paste the data and it looks beautiful. I am looking to remove this step but am unable to figure out how to get applescript to select the table and body rows of the inDesign template.
Neither of the following seem to work.
set selection to body rows of table 1 of active document
select body rows of table 1 of active document
Any help on this would be great.
Unfortunately the select command only works for a single row, and not all of the rows in a selected table.
Essentially, you must go row by and decide the row type. Once you've decided the row is a body row, you can select it.
The syntax for adding a selected row to another selected row is super tricky, especially without an example. See the complete script below.
tell application "Adobe InDesign CC 2015"
set allBodyRows to every row of every table of every story of active document whose row type is body row
set bodyRow to {}
repeat with i from 1 to (count allBodyRows)
set bodyRow to item i of allBodyRows
if i = 1 then
select bodyRow
else
select bodyRow existing selection add to
end if
end repeat
end tell
I think you need to reference your table differently. Try this:
set allTables to every table of every story of active document
set myTable to item 1 of allTables
Then you should be able to select rows:
tell table myTable
select first row
end tell
--author by RyuAutodidacte
tell application "Adobe InDesign 2020"
tell active document
--When the selection is a text frame
set FirstBodyCell to index of first cell of table 1 of selection whose row type is body row
set LastBodyCell to index of last cell of table 1 of selection whose row type is body row
select cells FirstBodyCell thru LastBodyCell of table 1 of selection
end tell
end tell

Open default excel data form for specific table with macro

Im working on a speadsheet with multiple large tables whose info is entered via spreadsheet based userforms i have created, as i am not familiar or comfortable using vba userforms, and i am trying to call entries back up in order to edit them.
The easiest way i can think of to do this is to open the default excel dataform. What i need to know is; is there any way to open this dataform for a specific table with criteria already entered?
eg. I need to edit a product table, so i already know that im editing the product table and i know the name for the product. I have a little userform, again spreadsheet based, where i select the entry type(in this case a product) and then enter the product name. What i want to do is use that info to open a dataform for the product table with the criteria field of the name already filled out so as to reduce time spent searching for the entry as these tables have hundreds of entries.
For this simple example I take your Worksheet with the products is called "Products". There are two columns with Names in column A and IDs in column B
On the Userform I place two textboxes called
TextBox_Productname
TextBox_ProductID
I then added the following code to the Userform that will trigger whenever the value of the productname textbox changes and it looses focus.
Private Sub TextBox_Productname_Change()
' Clear the content of all Textboxes but the Productname
TextBox_ProductID.Value = ""
' Analyse the Cells in the Worksheet called "Products"
With Worksheets("Products")
' Assume in the first row are the headers so start
' looking at the second row and go to the final one
For i = 2 To .UsedRange.Rows.Count
' check whether the value in the first column
' matches the value of the Textbox_Productname
If .Cells(i, 1) = TextBox_Productname.Value Then
' If there is a match copy the values of all
' the other columns to the textboxes
TextBox_ProductID.Value = .Cells(i, 2)
End If
Next i
End With
End Sub

Handling editing an NSTableView

I have an NSTableView backed by an NSArrayController subclass. The data displays correctly in the table when the app loads, so all is good there. I want to add a new row to the table, so I created an override for addObject to handle my custom object. When called, addObject inserts the new object into the underlying array, but the new row is the last row in the table, (makes sense, I think, as its added to the end of the underlying array), but I want the new row to be inserted as the first row. So I changed my addObject to insert the new item at index 0 (insertObject:atArrangedObjectsIndex:). Now the new row is inserted as the first row and the cell in column 0 is editable (Yeah!). BUT, when I tab to the next cell (in column 1, row 0), the selection jumps to the last row in the table and makes the cell in the second column editable. Not what I want. So how do add a new first row to my table? Make it editable without the selection switching to the last row?
I found the problem. I was programmatically sorting the table as items were added. The sort kicked in after I entered a value in the editable filed.

Resources