HOPE someone knows how to do this? - string

Col containing String Results
I have a Named Range, "cust_tags", and am looking for the best way to enlist each Customer to appropriate tags without creating a Concatenated String in their associated column. Maybe its not possible? Please see image for reference. Would prefer the result to be a Sereies of Validations, strung within the cell.
I Split the existing range values by "," delimter and produced a range. And was able to filter that to a unique list for creating the validation named range. but have been stuck at that point since.

Related

Check if strings in column start with any of the strings in an array?

I have a column containing strings. For each row in the column, I want to check if the string starts with one of several strings contained in an array. This array can contain any number of strings to check against the column.
The output I want is an array {TRUE;FALSE;TRUE;TRUE;etc} where it returns TRUE if the string begins with any of the strings contained in the array.
Anyone know how to do this? Thanks!
Edits for clarification: Office 365 (version 2109). I can't share the spreadsheet itself, but the column contains values like {1.1;1.1.1;1.1.2;1.2;1.3;etc}, and the arrays in question are things like {1.1;1.2}, so I want it to know which cells in the column begin with 1.1 or 1.2 in that case. So it's basically a hierarchically ordered list and I want to be able to pull into an array whether a given row of data is either a child of or is itself any of the items in the array.
Ideally it would be a formula only solution but I'm cool with VBA if it's necessary.
Example data
Bear in mind that in the real data there are many cells in column B which include way more than just two entries.
Assuming the first entry to be checked is in A1:
=0+LEFT(A1,LEN(MyArray))=MyArray
placed somewhere within the worksheet, will produce a spill array of the same dimension as MyArray and comprising the required Booleans. I leave it to you to decide what to do with that resulting array.
We can use MMULT and MATCH to return the correct array:
=LET(
lkprng, FILTER(A:A,A:A<>""),
depcll, B2&CHAR(10),
depclm, FILTERXML("<a><b>"&SUBSTITUTE(depcll,CHAR(10),"</b><b>")&"</b></a>","//b"),
dep, TRANSPOSE(depclm&""),
mtch, --(ISNUMBER(MATCH(LEFT(lkprng,LEN(dep)),dep,0))),
mmt, MMULT(mtch,SEQUENCE(COUNTA(dep))),
TEXTJOIN(CHAR(10),,FILTER(lkprng,mmt>0,"")))

Excel - Search a cell for text strings from an array and display matched strings

I have a large-ish spreadsheet of about 1400 rows. One of the columns in that row has been populated from a free-flow text and contains details about numerous items people are requesting. There's no consistency about what's in the text box though.
Image 1 has an example of what the data looks like. C2 is the cell with the data in is. D2 is where I want to extract the list of things from C2 to. If an item appears multiple times I only want it to show once.
Example image of data
The list where the things I want to look for is on a separate sheet (Example of list array) and the list is defined by the range name "items" and runs from A2:A95.
I'm using Excel365 (despite the example screenshots) and have been trying various solutions from here on SO and various other Excel help pages but can't find anything that will work how I've got things setup. I've nothing against using VBA if that's the only way to do it, but would prefer a simpler solution if possible.
Thanks in advance.
I created a Named Range for your reference list so in my formula ThingsToLookUp is referencing the range A2:A9 in my sample file below.
=TEXTJOIN(", ",TRUE,IF(ISERROR(SEARCH(ThingsToLookUp,C2)),"",ThingsToLookUp))
Note that you will stumble on some edge cases here with SEARCH. For instance, if the string has Crossbow you will always output Crossbow and Bow since the later is a substring of the first. Less important but this solution also outputs the items in the order as they appear on the reference list, not as they appear in the input string.

How can I remove an item from a cell's validation list when the cell already contains a value on that list?

I would like to remove an item from a cell's validation list when the cell already contains an item that has been selected from that validation list, in order to prevent the same item being re-selected in that cell.
Suppose an empty cell has the validation list {10,20,30,40,50}. When I select, say, '20' and then go back into that cell's validation list, I want to just see {10,30,40,50}. If I then select, say, '40' and go back into the validation list again, I want to see {10,20,30,50}, etc. It's important this also works for text values.
I originally viewed this problem as being about creating 2 lists and joining them together; e.g. in my first example, removing '20' can be thought of as creating lists {10} and {30,40,50}, so I tried using the 'comma' operator to join two ranges in the Data Validation dialogue, without success. I tried the same approach in a named formula and using that in the DV dialogue. Same result.
I created a UDF:
Function UNION(rRng1 As Range, rRng2 As Range) As Range
Dim rRng12 As Range
Set rRng12 = Union(rRng1, rRng2)
UNION = rRng12
End Function
and tried this in both the DV dialogue and via a named range. Still didn't work.
[EDIT]: This functionality needs to work in a structured table, where one of the columns is updated from the validation list.
I've concluded that I need to use an array formula within a named range, and reference this from the DV dialogue, but I'm not clear on how this can be done?
Here's what I came up with. It will work for numbers, but will probably need some work if your list is text.
In E1:E5, put your list (10,20,30,40,50). In G1:G5, put the formula
{=SMALL(IF($E$1:$E$5*($E$1:$E$5<>$A$1),$E$1:$E$5,""),ROW())}
That takes the list from E, removes the number in A1 that matches, and sorts it. Now create a named range called dvExclude with this as the RefersTo
=Sheet1!$G$1:INDEX(Sheet1!$G$1:$G$5,COUNT(Sheet1!$G$1:$G$5))
The G range will have errors at the bottom and this will exclude those - COUNT only counts numbers, not errors.
Finally, set up your data validation in A1 as List and =dvExclude.

Get Cell value by ID in Excel (VBA)

Good day, I set some IDS to some cells in Excel using this:
ActiveCell.id = "whateverID"
I don't know if those IDs are saved, and now I need to get the Values of those Cells but by ID, I don't have any idea on how to get it done, I need it because I want to get the values of specific cells using their IDs if such cells change their position, hope you understand.
Or if you know a better way to get it done the better.
I need it because I want to get the values of specific celss using their IDs if such cells change their position, hope you understand.
For that don't use ID's. Name the cell. For example
ThisWorkbook.Sheets("Sheet1").Range("A1").Name = "whateverID"
Now even if that range moves, you can always use the following to write/read that cell
WRITE
ThisWorkbook.Sheets("Sheet1").Range("whateverID").Value = "Something"
OR
READ
Debug.Print ThisWorkbook.Sheets("Sheet1").Range("whateverID").Value
You might also want to read more about Define named cell references or ranges

Can I add a value to a Named Range?

I have a Named Range setup in an Excel worksheet which I'm using to supply values for a Data Validation drop-down. My source formula is, basically, this:
=INDIRECT( "OnePartOfTheRangeName" & "AnotherPart" )
The range changes based on another value in the row, so that's why I have to combine strings, etc.
I want to add an extra value to the Data Validation list but am not having any luck with that. I thought that if there was some sort of "Union" function I could combine the INDIRECT list with the single value, but I haven't been able to find such a function.
Does anyone know another way to solve my issue?
Excel is quite specific in its error message (indeed, rather a nice change!):
so I doubt worth too much effort in attempting a direct approach. And I am bearing in mind that over three years without a solution to a fully understandable question probably means "it is not possible".
However an indirect approach might serve, though for that some details may be missing - for example how your named range is being constructed at present. For the purposes of illustration, assume that is named Part1 and refers to R1:R12, with blanks at the end (to allow room for expansion) and blanks in the middle (to show versatility). Assume 'another part' is named Part2 and refers to S1:S10, also with blanks in the middle and at the end (and also at the start).
The Data Validation might then be a List whose Source: =whole is the range T1:T22 named whole.
T1 would then be populated with:
=IFERROR(INDEX(Part1,SMALL(IF(ISBLANK(Part1),"",ROW(Part1)-MIN(ROW(Part1))+1),ROW(A1))),IFERROR(INDEX(Part2,SMALL(IF(ISBLANK(Part2),"",ROW(Part2)-MIN(ROW(Part2))+1),ROW(A1)-SUMPRODUCT(--NOT((ISBLANK(Part1)))))),""))
(courtesy of Get Digital Help) entered with Ctrl+Shift+Enter and copied down to T22.
This is dynamic in that adding an entry in ColumnR for example adds that into ColumnT which in turn adds into the validation drop-down.
Disadvantages include that the dropdown is not sorted in order if S and T entries are not sorted and the 'room for expansion' remains evident in the drop-down.

Resources