how to handle long text in gridjs column - text

Is there a way to handle long text ion column like ellipsis.js does? The column has 150 words, it should only show 50-60, and then show entire when hovered over with mouse.

Related

Excel displays incorrect cell data, disappears

Data in my spreadsheet seems to be stored correctly but is displaying wrong.
Each row is displayed in the subsequent row. Row 1 data is not displayed. Row 2 data is displayed in row 1. Row 3 data is displayed in row 2, and so on. If a cell in Row 2 is double-clicked, the correct cell contents are displayed in the formula bar, while the cell contents being displayed disappear.
Also, all text appears to be vertically aligned along the top inside the cells, even though this option isn't chosen. (text appears shifted to the top of each cell)
Sorry if this seems confusing, I appreciate the help. Below is a picture of what all the text looks like, and an example of the cell/formula bar displaying different contents
The modification of the font size can indeed cause such an issue, although normally font size modification also causes row heigth update.
I would advise you to do following modifications to your macro:
Currently:
Sheet2.Rows("2:" & Rows.Count).ClearContents
Sheet2.Rows("2:" & Rows.Count).ClearFormats
Sheet2.Cells.Font.Name = "Calibri"
Sheet2.Cells.Font.Size = 11
Change it into:
Sheet2.Rows("2:" & Rows.Count).ClearContents
Sheet2.Rows("2:" & Rows.Count).ClearFormats
As you see, just drop the formatting specification.

Determine if a cell has a button over/in it

How can I use VBA in excel to determine if a particular cell has one or more buttons in it?
I have a spreadsheet with 50 rows. Each row has a series of data entry fields, and then in column S, there are two buttons to do some calculations based on that data. The buttons all run the same macro, and check which row they are in to determine which row to act on.
Periodically, a user will delete one or more rows, once that data is no longer relevant. When this happens, I want to insert the same number of new rows onto the bottom, to ensure I always have 50 data rows. I can copy and paste e.g. S49 to S50, and the buttons will appear in S50, and work as intended, but I can't tell if one row or n rows have been deleted, so I don't know whether to start copying from S49, S48, or Sn.
If I write a for n = 1 to 50 loop to cycle through each row of column S, how can I check to see if there is a button present in cell Sn?
Edit: with #Michael's answer below I realised I needed to loop through the buttons, not the cells. While Michael's solution correctly answers my question as asked, in my particular application it is a little simpler:
Dim lastBtnRow as Integer
Dim b As Button
lastBtnRow = 0
For Each b In ActiveSheet.Buttons
If b.TopLeftCell.Row > lastBtnRow Then lastBtnRow = b.TopLeftCell.Row
Next
Then it's just a matter of copying and pasting S:lastBtnRow to S:lastBtnRow+1 through S:50
Cells don't have a property that identifies objects sitting in them, but objects have properties about where they're located.
You need to instead build a loop through all buttons on the sheet and test where they're located. If you're dealing with Form Buttons (and not ActiveX Buttons), then this is a simple loop that will count the number of buttons located in the cell you currently have selected:
Sub ButtonLoop()
Dim b As Button, i As Long
For Each b In ActiveSheet.Buttons
If b.TopLeftCell.Address = Selection.Address Then i = i + 1
Next
MsgBox i
End Sub
If you want to check the number of buttons in each cell, you can either write an outer loop that loops through each cell, and then use the loop above as the inner loop to check for buttons in the current cell in the outer loop; or more efficiently use a data structure such as a dictionary to increment a counter for each cell address encountered.

Replace old values in new values from an Excel Table en masse

I have a large table with about 1,500 values. And I need to replace the "old" values with the "new" values in the table. Basically, I need to "find and replace" en masse.
Column A
Column B
Red
Cherry
Blue
Indigo
If we were take the example above. Say I have a column that has a list of all of our products. Red car, blue mouse, etc. What I need to do is say "Look in column C (containing the products) for the value in column A and Replace it with the value in column B".
So, for example. Let's say I have "Red Car" I would want it to now say "Cherry Car". This is a simplistic way of putting it, but there are around 1,500 values and they are all just numbers. So it's not as simple as doing a find and replace unless I want to spend days finding and replacing and hoping I did it all right.
Here's an example of what it really looks like:
Old Value
New Value
653111
21870538
694182
21212412
653141
34123451
Table of Products
653111xyr
694182jfh
653141ren
Maybe this helps you:
=INDEX(Sheet2!B:B,MATCH(NUMBERVALUE(LEFT(A1,6)),Sheet2!A:A,0))&RIGHT(A1,3)
Sheet2 in this case contains the old and new value data.
A1 is the current value you want to have changed.
This is provided all the data has same length of numbers and characters.
I would suggest using VBA (or if something similar can be done using Office.js) to iterate over each of the old/new value pairs, and programmatically do a global Find/Replace on the products sheet.
Using VBA:
Dim mappings() As Variant
mappings = Worksheets("Mappings").UsedRange.Value
Dim row As Integer, rowCount As Integer
rowCount = UBound(mappings, 1)
For row = 1 To rowCount
Dim wks As Worksheet
Set wks = Worksheets("Products")
wks.UsedRange.Replace mappings(row, 1), mappings(row, 2), xlPart
Next
Given the number of products and mappings you have, I think this likely will take some time to run.

How to find the value of column name and row name when a value at the intersection is matching a condition

How to find the value of column name and row name when a value at the intersection is matching a condition
I have this data
TC1 TC2 TC3
TC1 100 87 95
TC2 88 100 99
I need to return the combinations where value is greater then 95 like:
TC1,TC1 TC1,TC3 TC2,TC2 TC2,TC3 and so on.
Can anyone help here?
This is for Excel 2016.
So, you've got your data:
Highlight it, and then click 'Format as Table' from the Styles Group in the Home ribbon. (yes, your table has headers)
With this table in focus, navigate to the 'Data' ribbon, and click 'From Table/Range' in the 'Get & Transform Data' group. This will open the query editor. If you're not used to it, don't worry. Although it can get quite complex in here, we're going to be pretty straightforward.
Highlight columns TC1, TC2, TC3 (Hold down [control] and click each column header). Go to the Transform ribbon, and click on 'Unpivot Columns' in the 'Any Column' group. Look at what happens, it's awesome.
Now, click the arrow next to the Value column. Go to 'Number filters' on the drop down. Pick, 'greater than equal to.' A 'Filter Rows' dialog opens. next to 'is greater than or equal to' put in 95.
Click OK. Your data set is filtered. Yes! Go back to the home tab, click 'Close & Load'
Admire your gorgeous list of tuples for values greater than 95.
Good luck! Hope it helps.

Is it possible to display a value based on presence of a cell border?

We are looking at doing some data import. There is a very large complex sheet which has some items grouped together using borders around cells in one column. The only indication that the items are grouped is the fact the group is surrounded by a border. Items ungrouped have no left and right border on the cell (may have top and bottom border as items above and below maybe grouped). As an initial exercise we want to add a column that displays true if an item is grouped. So if there is a border display a value like one. Does anyone know if this possible?
Use this custom VBA function:
Public Function GetBorder(ByVal Rng As Range, Idx As Integer) As Boolean
GetBorder = Rng.Borders(Idx).LineStyle <> xlNone
End Function
It takes two arguments: cell and index of border (7=left, 8=bottom, 9=top, 10=right). Returns TRUE or FALSE.
Now if you want to get info about bottom border of cell A1 you should:
=GetBorder(A1,8)

Resources