Ever since i added a multiple language option for my computer, Excel decided to turn all my decimals into commas. I need to turn them back into decimals again. How do i do this with least amount of work? If you know an EASY way to do this, emphasis on easy, please tell. When it is converted, i need a number, not text or anything else. I'm using Microsoft Office Professional Plus 2010.
I tried the approach where you make this formula in Excel
=SUBSTITUTE(A4;",";".")+0
Which should, i'm assuming, get cell A4, change comma into period and then by adding 0 convert to number. My original number is 17.6, now i'm getting 41807.
My best choice to use the below function which can help to convert the text to numbers also at the same time. Its very useful in cases where some systme reports are shared with different number formats
=NUMBERVALUE(SUBSTITUTE(SUBSTITUTE(E3,".",""),",","."))
There're two options for you.
1) change regional settings on your PC:
2) use Application.DecimalSeparator in VBA code (e.g. in Workbook_Open event):
Private Sub Workbook_Open()
Application.DecimalSeparator = "."
End Sub
Related
The situation:
I am working on an Excel file that offers some worksheets to calculate different things. The last of these worksheets is a summary of all the others that is preformatted for perfect printing on a standard paper sheet. I want to print this summary by clicking a button on the main page (first worksheet). The code behind this button is stored in "Table1" and looks like this:
Sub Print()
Worksheets("Table5").PageSetup.PrintArea = "B2:N48"
Worksheets("Table5").PrintPreview
End Sub
The problem:
I've got a german Keyboard with "," as decimal separator on the NumPad. My whole system uses the "," as this. After opening the file, I can just enter something like "1,4" in a cell of choice and everything works. My problem starts when printing the summary via VBA code (see above). After this, pressing my NumPad's "," results in getting a "." instead. The standard "," of the keyboard still works as supposed.
If I accidentially use the NumPad after printing, type "1.4" in a cell and hit Enter, the cell gets a user defined format as date (01.04. or in your case propably 01/04 or something else) and crashes everything.
What I tried:
I made a simple test file with only the two code lines above and just a blank space to print. I found out, that the problem only appears, if I really print the summary. Starting the preview and then cancelling it before printing does not cause the problem.
I checked the file with Excel 2010 and 2016 and the problem appeared in both cases.
If I save the file, close it and open it again, the problem is gone, but new formatted cells will stay and crash the file.
What I also tried is checking Excel's options before and after printing, but nothing changed.
My guess:
There might be a problem with Excel-VBA's "PrintPreview" in general. It would be nice to get a confirmation of my problem, a solution for it or a workaround. I cannot change the printing process to standard printing, because my real file is much more difficult.
Best wishes
RaspiManu
I was able to recreate the problem. The odd thing is that under File > Options > Advanced the decimal seperator symbol will still show as the comma. However the problem gets fixed with:
Application.DecimalSeparator = ","
Which would set the decimal seperator to the comma again.
Edit, I guess it's a known bug as I found this question on the same issue here. A solution provided there would be instead of Worksheets("Table5").PrintPreview use:
Application.CommandBars.ExecuteMso "FilePrintPreview"
However for this option to work, the activesheet needs to be the one you want to print from. So I would still prefer to use the first suggestion and set the DecimalSeperator.
Long story short.
Windows 10.
Office 2013/2016
Document is exported from other system.
Cell contains hyper link with lets says "105,000" the other same is custom setting 105,000(#.###)
In this case "," represent thousands.
Client download report. Here is where regional settings and excel settings hit in.
Custom setting is converted to 105.000 but hyperlink "105,000" stays the same.(in this case "," means decimal. Should be converted to thousands)
Client claims it worked on windows 7.
Any ideas?
In general, whenever something like this happens with me in Excel I try one of these:
In Excel - =Replace(TheHyperlink,",",".")
With VBA - =fnStrChangeCommas(TheHyperlink)
Public Function fnStrChangeCommas(ByVal myValue As Variant) As String
fnStrChangeCommas = Replace(CStr(myValue), ",", ".")
End Function
I hope someone will be able to help me sort this one out because I've been crawling the Internet for some time now and could not find any obvious reason why the behavior of my macro under Excel works for some users (including me of course) and does not work on some other users' laptops.
My objective:
Write from a VBA SubRoutine a vlookup formula in one cell. Based on that vlookup, either it finds something and it displays a text A or the vlookup throws an error and it then displays a text B.
The situation
Here is the formula if we were writing it directly in the sheet from the end-user's perspective: =IF(NOT(ISERROR(VLOOKUP(C2,DataSet2!$A$2:$A$12,1,0))),"Direct Report","Team member of direct report")
When we copy/paste that formula on a PC where the macro fails directly in the spreadsheet. It works.
When we run the macro actually trying to incorporate that formula in that exact same cell, it fails and throws an error 400.
Here is now the VBA code attempting to write the above formula in the cell:
formulaString = "=IF(NOT(ISERROR(VLOOKUP(C" & CStr(counter + 2) & systemListSeparator & "DataSet2!$A$2:$A$" & CStr(2 + totalDirectReportsCount) & systemListSeparator & "1" & systemListSeparator & "0)))" & systemListSeparator & """Direct Report""" & systemListSeparator & """Team member of direct report"")"
Selection.Offset(counter, 0).Formula = formulaString
So the above 2 statements, as you'll have understood probably, are included in a loop and for every single row I have, I want to add that formula in the first cell from the currently selected cell.
What drives me crazy is that: it works fine on my PC, it works fine on my colleague's PC who is in Finland, but on another colleague's PC also in Finland, it does not. I have Windows 10 and Office 2016, she has Windows 10 and office 2016 as well...
So I am really wondering if there could be some regional settings or Excel settings or System Settings which could make HER Excel not interpret my "formulaString" as viable for her laptop. I have made sure to fetch the list separator to avoid those usual regional settings easy traps but would there be other similar traps I am not aware of?
Thanks a lot for any hints I could follow to progress on my investigations.
Kind regards,
Nicolas C.
This is really a tricky point, but fortunately VBA provides an excellent solution.
Simply write the formula in Excel, select the cell and run the following code:
Public Sub TestMe()
With ActiveCell
Debug.Print .Formula
Debug.Print .FormulaLocal
Debug.Print .FormulaR1C1
End With
End Sub
In German Excel, this is what you would get:
=SUM(C1+D1)
=SUMME(C1+D1)
=SUM(RC[2]+RC[3])
Then rebuild your formulas, using only .Formula or .FormulaR1C1 and the result from the immediate window. Thus your colleagues from all over the world would be really happy. As noted in the 3 examples, the first and the third one always give the same answer, following the en_US format.
Another option is that Excel and VBA do not like your formula, because of the decimal separator in Finland, being different from the decimal separator in the USA. See How to add hardcoded float number values to the formula using VBA to change it a bit.
Solution
Nicolas C. edit: All the above comments and hereby answer have helped me solving my issue. Thank you very much guys for your prompt reaction and feedback. You really saved my day. So the root cause was indeed that I had tried to capture the end-user's system preferences on his/her locale and regional settings and making use of his/her list separator (which was ; actually) within the VBA script which was a bad move since, as mentioned by #AxelRichter and #Vityata, within a VBA script, .Formula needs always to be written in the en_US format, that is english function names, commas, etc.
I have now removed my user related list separator and replaced it with traditional commas and it solved my issue.
A little background about what I'm trying to do:
My userform is going to be used to grade employee training with the results being added to an excel spreadsheet. The checkboxes in my form are representative of the different kinds of mistakes they can make and each mistake ideally has a quantity box that will specify how many times each mistake was made if its box is checked. I need both in one cell, as each row is 1 test for each employee. Here is an example of my userform:
Mistakes Screen Shot
All checkboxes and textboxes share the same number and I've already programmed them to automatically insert a 1 quantity if the box is checked/empty if unchecked. (Of course the quantity must be editable in case a mistake type is duplicated.)
So far I was able to use a loop with a string to get the checkboxes to put their captions into the single cell using this code:
Dim CheckBox As Control
Dim Mistakes As String, delimiter As String
For Each CheckBox In Me.Frame_Mistakes.Controls
If TypeOf CheckBox Is MSForms.CheckBox Then
If (CheckBox.Value) Then
Mistakes = Mistakes & delimiter & CheckBox.Caption
delimiter = " | "
End If
End If
Next
With Sheet1
.Cells(emptyRow, 4).Value = Mistakes
End With
However, so far I have been unable to figure out how to get the quantity to be added at the end of each mistake preceding the delimiter. I would prefer it if I could get the string to be in this format: Mistakes Format in Excel
If my intentions are unclear, I apologize. I am incredibly new and honestly surprised I was able to make it this far. Please and Thanks!
So, if I understand you correctly, You want the output of the Mistakes cell to read
[Caption of checked box](x[Number in Text Box])|[Caption of checked box](x[Number in Text Box])...
If that is so, you simply need to add a snippet of code to the end of your 'Mistakes' variable so that it reads:
Mistakes = Mistakes & delimiter & Checkbox.Caption & "(x" & TextBox.text & ")"
Where things get difficult is that you will need to differentiate between text boxes so that only the one that applies to the relevant checkbox is being used. You could do this in a number of ways, such as passing the Textbox as an argument, or with a switch case to name a few.
Another problem is making sure that the textbox only uses numbers. The way that I accomplish this is with a combination of the IsNumeric() and Val() functions. You first check if the value is numeric, then store it in an int using the Val() function. Since you only need it for a string, though, using the IsNumeric() function alone should be fine.
If you need more specific clarification, I would need to know exactly what you are looking for.
I am trying to make a customer link by concatenating two cells containing parts of the URL string, but for some reason it is not working.
These are the strings:
A1:
https://www.correosexpress.com/web/correosexpress/envios4?p_p_id=chxseguimientoEnviosPublico_WAR_chxseguimientoEnviosPublicoportlet&_chxseguimientoEnviosPublico_WAR_chxseguimientoEnviosPublicoportlet_struts.portlet.action=/view/getShippingPublic_execute&_chxseguimientoEnviosPublico_WAR_chxseguimientoEnviosPublicoportlet_shippingNumber=
A2:
(Number we will add in each custom link)
A3: &_chxseguimientoEnviosPublico_WAR_chxseguimientoEnviosPublicoportlet_zipCode=
A4: (number we will add in each customer link)
I am trying the following and receiving an error every time:
=HYPERLINK(CONCATENATE(A1:A2:A3:A4);[LINK])
I tried adding text instead of A1 but the string is too long (more than 255 characters).
I have hit the 255 character limit several times, and unfortunately there is no way around it. You can work around this with VBA, or you can shorten the url in A1 using something like goo.gl url shortener, and then concatenate.
Try this instead:
=HYPERLINK("CONCATENATE(A1,A2,A3,A4)","[LINK]")
NOTE: I put commas instead of colons and semicolons, but you may need to change them back where you are.
I needed to send some data to a PHP-Script and i needed to work on windows and osx.
After some reasearch and trying i ended up with this visual basic function:
Sub SendImportData()
Dim URL As String
URL = "https://example.com/import.php?" & Range("M1").Value
Open "temporary.url" For Output As #1
Print #1, "[InternetShortcut]"
Print #1, "URL=" & URL
Close #1
Shell "temporary.url"
End Sub
Then i built the querystring in excel itself (M1). But you can also built it within visual basic. This will give you more flexibility.
I also want to mention that you need to url-encode the values in your querystring.
There is still a limit of how long a url can be in different browsers. But its much higher than the excel limit.
Hope i could help someone.