I Have a column which contains multiple unique and duplicate values and I'm looking to extract only the non repeating values. How do i go about it?
Example:
A2: 28; 33; 34; 37; 44
A3: 28; 34; 37
I'm trying to get:
A4: 33; 44
example
I've tried finding an answer but couldn't find a solution for this exact problem.
=LET(a,TEXTJOIN(";",,B2:B4),UNIQUE(--TEXTSPLIT(a,";"),TRUE,TRUE))
I don´t see a way of doing this using only formulas. The best approach would be to save those values as a .csv file, and importing that csv file into Excel. Then, using Power Query, you would do the necessary transformations in order to get the desired result.
Here is a step by step solution:
Get your data into a .csv file
Import the csv file by going into Data > From Text/CSV,= and selecting the file. Then, select the delimiter "Semicolon" and click "Transform Data" to open Power Query:
With Power Query open, select all columns by pressing Ctrl + A, and then go to the "Transform" tab and click "Unpivot Columns". You should have something like this:
Delete the "Attribute" column
Remove duplicates from "Value" column
Click "Close & Load" in the Home tab
You then will have the desired result:
I have an answer which ignores any spaces between the values and formats the result by putting only one space between the values. Call the function with two parameters, the values of the two cells to be merged:
Public Function Uniques(stra As String, strb As String) As String
'Uniques("11; 12; 13; 14; 15", " 11;11; 14; 15; 88; 16 ") ==> "12; 13; 88; 16"
Dim ar() As String, delim As String, ss As String, s As String, alen As Integer
Dim z As Integer, p As Integer, c As Integer
delim = ";"
s = Replace(stra & delim & strb, " ", "")
ar = Split(s, delim)
s = delim & s & delim
alen = UBound(ar)
For c = 0 To alen
If ar(c) <> "" Then
ss = delim & ar(c) & delim
p = InStr(1, s, ss)
If (p > 0) Then
p = InStr(p + 1, s, ss)
If p > 0 Then
s = Replace(s, delim & ar(c), "")
For z = c + 1 To alen
If ar(z) = ar(c) Then ar(z) = ""
Next
End If
End If
End If
Next
If (s = delim) Then
Uniques = ""
Else
s = Mid(s, 2, Len(s) - 2)
s = Replace(s, delim, delim & " ")
Uniques = s
End If
End Function
if the two cells have the same value returns empty string ("")
Use Reduce, Textsplit and Hstack to split each row and add it to a single-row array, then use Reduce again to check the number of times each element of the array occurs, and concatenate it to the output if it only occurs once.
=LET(
data, DROP(
TOCOL(A:A, 1),
1
),
row, DROP(
REDUCE(
"",
data,
LAMBDA(a, c,
HSTACK(
a,
TEXTSPLIT(
c,
"; "
)
)
)
),
,
1
),
MID(
REDUCE(
"",
row,
LAMBDA(a, c,
IF(
SUM(
N(
c =
row
)
) = 1,
a & "; " &
c,
a
)
)
),
3,
99
)
)
Having a string I would be able to add any string between every characters (not at the beginning and end). For example:
Having string "abcd" and adding string " - " should give the following result:
val s = "abcd"
val result = "a - b - c - d"
What would be the recommended way to accomplish it in Scala?
Simply
"abcd".mkString(" - ")
// "a - b - c - d"
Try
s.toCharArray.mkString(" - ")
Im generating a string variable from other string variables that themselves are generated in a button press and take their values from textboxes / user input. Simultaneously, the mass string variable is being loaded into a RichTextBox. While I do purposely use one VbLf in my mass string variable, I am encountering an additional point where a new line begins in my string where it is not supposed too. How can I avoid this?
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
numb = numbtxt.Text
year = yeartxt.Text
author = authortxt.Text
pages = pagestxt.Text
pgnum = pgnumtxt.Text
item1 = item1txt.Text
item2 = item2txt.Text
format = numb + ") """ + item1 + """" + vbLf + item2 + _
" - " + author + " (" + year + ") " + pages + " " + pgnum
rtf.Text = format
End Sub
I am expecting this:
https://i.imgur.com/5q5MME2.png
but I am getting this:
https://i.imgur.com/dCMAIqA.png
Any help would be very much so appreciated.
Please check your content of cour variable item2 containing the url. I guess, that this variable contains a line break at the end. Try to just print this variable with a leading and trailing char.
If so, you can either replace the new line character in item2 or try to substring the content.
To remove any unwanted characters from the input strings, you can trim them, or do a character replacement. For example, to remove CR/LF from the end of strings (untested, from memory);
numb = numbtxt.Text.TrimEnd( {vbCr, vbLf, vbCrLf, Environment.Newline} )
or to remove all occurrences;
year = yeartxt.Text.Replace(vbCrLf, String.Empty)
or;
year = yeartxt.Text.Replace(vbCr, String.Empty).Replace(vbLf, String.Empty)
etc. YMMV depending on the actual CR/LF character arrangments and language settings!
I have a dataset where the format of data is like this:
10 ¾ AB 02/15/19
I'm trying to convert the ¾ into .75 so that the data looks like:
10.75 AB 02/15/19
I am thinking of trying to iterate through each character in the string, but once I do so how can I convert the ¾ into .75?
Simple set of string replacements:
Public Function numerify(s As String) As String
numerify = Replace(s, " " & ChrW(190), ".75")
numerify = Replace(numerify, " " & ChrW(188), ".25")
numerify = Replace(numerify, " " & ChrW(189), ".5")
End Function
NOTES:
We replace the space before the fraction as well as the fraction to get the desired result.There may be other uni-code "fractions" you may need to consider.
Say I have a string that = Grilled Cheese
How would I echo the string without the space between Grilled Cheese with out changing the string?
Also if I had a string that variables but will always have a space, like a full name. I can show the first letter of the string:
WScript.Echo Left(strUserName, 1) will echo for example G
but how could I show the name after the space (= Cheese). Keep in mind the name after the space may change like "Cheesy" for example
WScript.Echo Mid(strUserName,null) does not work
Thanks!
The Replace function can be used to remove characters from a string. If you just echo the return value without assigning it back to the variable, the original string will remain unchanged:
>>> str = "Grilled Cheese"
>>> WScript.Echo Replace(str, " ", "")
GrilledCheese
>>> WScript.Echo str
Grilled Cheese
Another option would be the Split and Join functions:
>>> str = "Grilled Cheese"
>>> WScript.Echo Join(Split(str, " "), "")
GrilledCheese
>>> WScript.Echo str
Grilled Cheese
Split will also allow you to echo just particular tokens from the original string:
>>> str = "Grilled Cheese"
>>> WScript.Echo Split(str, " ")(1)
Cheese