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.
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.
I can't figure this out, Maybe you guys can help me.
I need to separate just the image name for example
xxqti8eli5h2f4abpiz2.jpg
lvfdpujvgkf75ve8ikob.jpg
In a separate column, I've a list of 8000 image name which I need to separate out any help from you guys is much appreciated.
http://images.XXX.com/image/upload/s--B3cI5sks--/c_limit,cs_srgb,h_600,w_600/xxqti8eli5h2f4abpiz2.jpg
http://images.XXX.com/image/upload/s--_3R1kbWq--/c_limit,cs_srgb,h_600,w_600/lvfdpujvgkf75ve8ikob.jpg
formula version:
=MID(A1,FIND("}}}",SUBSTITUTE(A1,"/","}}}",LEN(A1)-LEN(SUBSTITUTE(A1,"/",""))))+1,LEN(A1))
Since the image is always the last chunk of your string when you separate/split the string by a forward slash, you can use a really tiny UDF to get this functionality.
In a new VBE Module (Alt+F11, then right click your workbook and Insert>>Module), paste the following:
Function get_image(url As String) As String
'extract the last token from the url when it is split by forward slash
get_image = Split(url, "/")(UBound(Split(url, "/")))
End Function
Now you can use this new function in your worksheet:
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.
I'm trying to make a macro that, among other things, updates external file links in several cells, where the file location currently in the cells and that which I want to change it to are specified by the user in another tab.
I've tried to do this via find/replace; if I try to do this with the text specified in the code:
Range("b3").Formula = Replace(Range("B3").Formula, "\\folder\file", "\\folder\newfile")
Then it'll replace this text and the links update correctly. If I change the locations with inputs, say oldlocation and newlocation:
oldlocation= "\\folder\file"
newlocation= "\\folder\newfile"
Range("b3").Formula = Replace(Range("B3").Formula, oldlocation, newlocation)
This also works ok. But if I change the definitions of the locations (e.g. B3: "\folder\file"):
oldlocation= Range("b3").text
newlocation= Range("b4").text
It no longer works - passes over the line in the code with no change or error. I've made a quick check and Range("b3").text & "\folder\file" both seem to be text strings; after that I'm stumped. I've tried a few different find/replace formats I've found, but all with the same result. What am I missing?
The problem is when you define the string to be replaced as
oldlocation= Range("b3").text
the oldlocation variable will have the value of the cell (the data you see in the cell) not the formula of the cell that contains the current reference, so the replace function does not find the string to be replaced.
You have to extract the location that you want to replace from the Range("b3").formula string and work with that.
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