I am entering a string in a Userform in Excel-VBA from the user side of the form. I would want to know how to enter the Long Hyphen.
The Small Hyphen would be Shift + - the (the minus sign button next to 0).
How would you enter the Long Hyphen on the form as I am doing a string match in my VBA code on the back-end? It can be entered with Alt+0150, but is there another simpler way?
If the option of entering the Long Hyphen doesn't work then I will handle this value on the back-end through a find and replace method or something in VBA.
๐ There is only one "Hyphen"... โโ It's part of a แดแฉแฐแฅแชฦณ แดา แแผแฉแแฉแไธ
แดแแ called Dashes.
Examples:
Hyphen [-] (-)
Minus sign [โ] (โ)
En dash [โ] (โ)
Em dash [โ] (โ)
โฑ Your browser might render them differently, but the fonts above are supposed to be [Consolas or Courier 13px] and (Arial or Helvetica 15px). While they all kind of look the same in this font, those are four different characters.
The characters can be copy/pasted directly from here - โ โ โ into Excel (but not to the the VBA Editor), or can be produced along with 136,686 other Unicode characters, either:
with a worksheet formula, using the แดษดษชแดสแดส function:
=UNICHAR(9733) 'produces a [โ
] star character.
programmatically with VBA, using the ChrW function:
Range("A1") = ChrW(9743) 'puts a wee [โ] rotary phone in cell A1.
More about dashes โ
What they are
How to use them
"Stealing" Unicode characters from websites
There are all sorts of handy Unicode symbols โ so many that it can be hard to find "just" the right one.
However you can (and will!) find other Unicode symbols on web pages that you want to use programmatically. All you need is the symbol's code, which can be determined easily:
Copy/paste the symbol from your browser (being careful to copy only the single character; no spaces, etc.) into a cell in Excel
then, go to VBA's Immediate Window ( AltF11โCtrlG ), type:
MsgBox AscW([a1])
...(Where A1 is the cell with the character). Hit Enter, and the character's Unicode code will display.
You could also use Windows' built-in Character Map utility, or one of many third-party browser plug-ins. You can even paste a symbol directly into Google to learn more about it:
Finally, no discussion on the topic of Unicode would be complete without links to:
โโ๐ โThe Unicode Consortium (unicode.org) and,
โโ๐ โโศถษฆษ ๐๐ธ๐ธ๐ต ๐ฑ๐๐๐๐ โโโงโฃ ๐พ๐๐๐๐ฃ๐๐ฅ๐ ๐ฃโ โ(Yes, those are all plain text characters.)
...and if you're looking for a unique gift, or just want your name to go down in history for something that really matters, you can even adopt a Unicode character, starting at $100 แดsแด
!
Special thanks to Vinton Cerf for adopting the Unicode Leonard Nimoy's "Live Long and Prosper" symbol.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ๐
Related
Problem:
I have a sentence/word I need to past in an excel cell. It consists of an Arabic word, along with some numerical values (in English). For example, let's say I want to write the below
However, excel keeps returning the below
2,1 - ุงูุญุฏุซ
It you notice, the numerical values are always moved to the left of the word, while I want to keep it on the right.
I tried concatenating, but didn't seem to help. I am open to any solution, vba or not, as I have spent a lot of time on this with no luck.
I added this keyboard to my device and it helped me with that.
Central Kurdish Keyboard
Use it to write the numbers only, and use the normal arabic keyboard to write the rest of the text.
And note that it didn't work with the numpad, it worked only with the numbers row at the top - the one that has the special characters !##$%^&*()
I have a csv file which is filled automatically through a java programm. I have a line which have the following text when I open the text in Notepad++:
-LRB- from the PMI Practice Standard for Work Breakdown Structures , Oct 2000 -RRB- '',"no","f1_FRAG:1.0","f2_specialChar:1.0","f3:15.0","f4:7.0","f5:0.0","f6:2.0","f7:0.0","f8:3.7612001156935624","f9:7.0","f10:1.0","f11:1.0","f12:0.0","f13:0.0","f14:0.0,"f15_ROOT:1.0","f16_specialChar:1.0","f17_NOTHING:1.0","f18_IN:1.0""
But when I open it in excel sheet, there are two problems:
1) When I click on the cell, I see #Name error and any click on the page causes an error. I even can't close the excel window normally. I also sometimes see something like =A228 or =B223 when I click on the cell. It sounds to be read as a formula, but it actually isn't.
2) The row is not shown completely. I can't see this part when I open the file using office excel:
",f15_ROOT:1.0","f16_specialChar:1.0","f17_NOTHING:1.0","f18_IN:1.0"".
Any help is appreciated.
Since the row starts with a - (minus sign), Excel is expecting a formula.
Manually, you could either:
add an ' (apostrophe) at the beginning of the line (which tells Excel that the cell contains text), or
Format the cell as text : Right-click the cell โ Format Cells โ Number tab โ Text
Ideally, to prevent this issue in the future, the Java program which generates the .CSV file should be changed to enclose text fields with " double quotation marks.
Oddly, that is the only field in your example that isn't surrounded by double quotes.
"-LRB- from the PMI Practice Standard for Work Breakdown Structures , Oct 2000 -RRB- ''","no","f1_FRAG:1.0","f2_specialChar:1.0","f3:15.0","f4:7.0","f5:0.0","f6:2.0","f7:0.0","f8:3.7612001156935624","f9:7.0","f10:1.0","f11:1.0","f12:0.0","f13:0.0","f14:0.0,"f15_ROOT:1.0","f16_specialChar:1.0","f17_NOTHING:1.0","f18_IN:1.0""
At the minimum, double-quotes should the used around any fields that begin with a symbol or contain a comma (like above).
1997,Ford,E350,"Super, luxurious truck"
The double-quotes will be recognized and removed by most apps that open CSV's.
Any field may be quoted (that is, enclosed within double-quote characters). Some fields must be quoted, as specified in following
rules.
"1997","Ford","E350"
Fields with embedded commas or double-quote characters must be quoted.
1997,Ford,E350,"Super, luxurious truck"
Each of the embedded double-quote characters must be represented by a pair of double-quote characters.
1997,Ford,E350,"Super, ""luxurious"" truck"
.
More about Comma Separated Value files:
Wikipedia: CSV Files - Basic Rules
RFC 2046 Standard
RFC4180 Standard
.
Surprisingly, I can't find any reference document from Microsoft that mentions starting text cells with an apostrophe. (I guess it's a secret, so if anyone asks, you didn't hear it from me.) :-)
The reason you are getting the #NAME error specifically is because Excel figures you're trying to enter a formula (because of the minus sign) but it doesn't recognize the Name of the function ("LRB")
I have been asked if there is any way to get Excel to produce an overstrike effect in a cell. My first attempt was the use the BACKSPACE character:
="A" & CHAR(8) & "B"
But the display does not seem to honor the BACKSPACE:
Is this a font problem? Is there a unicode approach ?
I hate to tell the client to search for a custom font.
EDIT#1:
For example. This code:
Sub XBar()
ActiveCell.Font.Name = "Arial MS Unicode"
ActiveCell.Value = "X" & ChrW(773)
End Sub
Visually produces:
but this is not a general solution.
You can extend the character set by putting one character on top of another BUT you can only do this with a limited set of symbols. These are known at the "Combining Diacritical Marks" and usually live towards the end of the font set.
For a spreadsheet document, I wanted to put in 9 recurring (ie 9 with a dot above it). This does not exist as one character but can be made by combining two.
First of all put in the 9, then from the Combining Diacritical Marks, choose the . and one will go above the other. I actually had to do this in Word and then copy and paste the new characters back to Excel to make them work.
Once in Excel, I used a look up to convert the digit 9 into the dotted digit 9 wherever I needed it.
Different fonts have different ranges of these characters. Arial Unicode MS has some unusual ones. You need to look at the fonts and choose the most appropriate for your needs.
However, on the whole, I don't think you can put a B on top of an A!
Are you trying to do this?
If so, then select the character(s) you'd like to strikethrough, click the arrow icon in the font section (circled below) and tick the box next to strikethrough.
See here for more information.
Having a hard time checking if cells contain a dollar sign ('$'), as Ecxel thinks I'm trying to make an absolute reference.
I'm working with imported data that includes a column of usernames, and many of the usernames have a '$' character at the end. In Excel, I'm omitting some of the data in the username column, based on strings they may contain. Some example-ish accounts:
chi_smithcleve
letter_admin
NYCDB140$
outside3
NYCPRD148$
ATLDB12$
chi_goadjames
I want to test the usernames for three conditions: they don't contain the string 'NYC', 'chi', or '$'. The character-strings are easy, but I can't figure out how to escape the dollar-sign character! All the documentation I've found suggests double-quotes as an escape mechanism in Excel, but that doesn't seem to be working. The primary formula that documentation says should work is:
=ISNUMBER(SEARCH(""$"",A2))
where I'm checking the cell A2 to see if the '$' character occurs. But Excel's just telling me that I have an error. I've tried several other possible escape characters, to no avail.
(I could do a 'character replace' function at some point upstream, to replace the '$'s with a more manipulatable character, but I'd rather just leave the data in same state as when it's received)
Try this, it is working for me.
=ISNUMBER((SEARCH("$",A2)))
How do I get the last character of a string using an Excel function?
No need to apologize for asking a question! Try using the RIGHT function. It returns the last n characters of a string.
=RIGHT(A1, 1)
=RIGHT(A1)
is quite sufficient (where the string is contained in A1).
Similar in nature to LEFT, Excel's RIGHT function extracts a substring from a string starting from the right-most character:
SYNTAX
RIGHT( text, [number_of_characters] )
Parameters or Arguments
text
The string that you wish to extract from.
number_of_characters
Optional. It indicates the number of characters that you wish to extract starting from the right-most character. If this parameter is omitted, only 1 character is returned.
Applies To
Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000
Since number_of_characters is optional and defaults to 1 it is not required in this case.
However, there have been many issues with trailing spaces and if this is a risk for the last visible character (in general):
=RIGHT(TRIM(A1))
might be preferred.
Looks like the answer above was a little incomplete try the following:-
=RIGHT(A2,(LEN(A2)-(LEN(A2)-1)))
Obviously, this is for cell A2...
What this does is uses a combination of Right and Len - Len is the length of a string and in this case, we want to remove all but one from that... clearly, if you wanted the last two characters you'd change the -1 to -2 etc etc etc.
After the length has been determined and the portion of that which is required - then the Right command will display the information you need.
This works well combined with an IF statement - I use this to find out if the last character of a string of text is a specific character and remove it if it is. See, the example below for stripping out commas from the end of a text string...
=IF(RIGHT(A2,(LEN(A2)-(LEN(A2)-1)))=",",LEFT(A2,(LEN(A2)-1)),A2)
Just another way to do this:
=MID(A1, LEN(A1), 1)