VBA to exceed character limit for hyperlink in MS Excel 2010 - excel

I am using MS Excel 2010 and I would like to create a function which allows me to concatenate several cells and construct a hyperlink that exceeds the max char limit in excel.
This post is similar (Stackoverflow Post) but I had several problems with the solution:
It used and older version of excel (not sure if this is relevant)
As indicated in the comments, the instructions are pretty rough (to say the least)
It was not clear to me if the subroutine or the function was the appropriate solution
I could get the subroutine code to work (but see #3) but I would really like it to be a function
Could someone clarify how to get this code to work such that it would be a function that can accept either cells or a concatenation statement ?
Thanks !

Related

Excel UDF not working on another computer

I have searched the internet and Stack Overflow, but couldn't find an answer to my problem.
I defined a UDF in Excel, it's saved in a module in an .xlam Add-In. The UDF works perfectly fine on my computer. Now I'm trying to use the workbook which uses the UDF on another computer (in a different language) with the same .xlam Add-In active. However Excel suddenly references the entire path to the add-in file as an "absolute path" instead of only showing the function name itself. The result is a #NAME? error because Excel doesn't find the UDF.
How I have written the VBA Code
How it should look
How it looks on another computer
Has anyone had this issue and found a solution for it? I could try to find a workaround without the UDF function but I'd prefer that it works this way. Another time the situation might be more complex ...
The problem with your UDF is the location of the .xlam file. You can find information on dealing with that by following the link in the comments above provided by Christofer Weber.
Having said that, I think it may be more beneficial for you to use the built-in formula that excel has for this which is EOMONTH()
EOMONTH() can be used to return both the last day of a month and the first day of a month (by finding the last day of the previous month and adding 1)
You can find more information on EOMONTH() here https://support.microsoft.com/en-us/office/eomonth-function-7314ffa1-2bc9-4005-9d66-f49db127d628

What is the simplest way to use a formula to detect if google sheets or microsoft excel is running, and execute the compatible formula accordingly?

Some formulas I'm using only work in Microsoft Excel but not Google Sheets, or a different formula that has the exact same result works in Google Sheets but not Microsoft Excel.
Is there a simple way to detect if Google Sheets or Microsoft Excel is running, and execute the compatible formula accordingly?
I am finding it difficult to believe this question hasn't been asked before but I couldn't find my specific question of the same file working in both Excel and Google Sheets.
I'm not concerned about scripts, just formulas.
There is no official way to determine if Microsoft Excel or Google Sheets is running through formulas, however with some versions of Excel =INFO("RELEASE") will return the version of Excel running, but this doesn't work in Google Sheets.
Thanks to #Slai, =ISERR(-"1pm") results in TRUE in Excel and FALSE in Google Sheets. Excel doesn't understand how to apply math to a time string value, where Google Sheets does, hence the error.
A simple IF statement using this logic can be =IF(ISERR(-"1pm"),"MS-Excel_formula","G-Sheets_formula")
If the formula you're using returns a number, a more simplified version is =IFERROR(GoogleFormula+"0am", ExcelFormula) however this won't work for non-numeric returned formulas because it adds 0 to the result which should not change a numeric result. For instance, =IFERROR(1+"0am", 2) returns 1 in Google Sheets and 2 in Excel.
If Microsoft decides to recognise "1am" or "0am" as numeric time values in future versions of Excel, the above if statements won't work as intended and Excel will attempt to execute the Google Sheets formula.
One boolean solution is to force an error in a function you absolutely know doesn't work in one or the other program. So #Slai 's example would work well no? Also, excel doesn't attempt to implement the Google only functions like ArrayFormula or Importrange &c. FWIW The minor discrepancies are the ones that catch me out - 'DSUM' for example frustrates me in that Google Sheets responds slightly differently to the Excel implementation under certain conditions. There will be others I'm sure but I've not yet found a definitive list or collation thread of these. (PS. I've not expanded my description of the DSUM idiosyncrasy as I suspect it'll be too far off topic).

Handling complex numbers in Excel spreadsheet

I doubt an Excel spreadsheet can handle this but it's worth asking, since I have been trying and searching for a long time with no success.
Entering this into a cell:
=complex(abs(-1.5*(-1.5)^(-1.5))),0)
and the cell output is #NUM!
The output should be: 0.8164966
I played with this a bit and didn't get anywhere - this article may explain why.
Link
it's complicated, and I think it's more than an excel problem
The following pdf has a nice write-up for using complex number functions in excel.
https://ccnet.stanford.edu/cgi-bin/course.cgi?cc=ee246&action=handout_download&handout_id=ID11300955936304
Seems like you have made a mistake inserting the parentheses.
The correct form is:
=COMPLEX(ABS((-1.5)*((1.5)^(-1.5))),0)
=0.816496580927726
This runs well in Excel 2013.

VBA - Pretty Print a Row in Excel

I want to print a row in Excel.
One row contains data for one project.
I want to print one row on one page nicely formatted. Meaning the value of one cell is the header and should be printed fat and centred, the other values should also be placed at fixed positions on the page.
Is this with VBA possible? When I was searching for this problem I only found results for printing a worksheet or a table or parts of it, but no results to use the values of the cells and formatting them.
Thanks in advance
As the other answers indicate, it is certainly possible in Excel VBA, but it is not really Excel's strong point.
What would typically be done to obtain the result you seem to be after is use a fully formatted Word document with fields that are then filled in with values from an Excel worksheet. You can even cheat a bit and use the Mail Merge \ Letter wizard to set everything up.
If you do want to do it all in Excel, you can find instructions and an example VBA macro here:
http://www.tek-tips.com/faqs.cfm?fid=4223
Template is a good way to do. With a macro there's better performance where it avoids the usage of volatile functions such as INDIRECT() However again it depends on how many volatile functions your worksheet carries.
Yes, it is possible when you use the Styles in excel. I know you can do Font formatting quite easily. Not sure about indenting it, but worth a try.
If style doesnt support it (it might in Excel 2010), you can always indent it via VBA (record a macro when you indent the values , it should look like this):
Selection.InsertIndent 1

Why is Excel's 'Evaluate' method a general expression evaluator?

A few questions have come up recently involving the Application.Evaluate method callable from Excel VBA. The old XLM macro language also exposes an EVALUATE() function. Both can be quite useful. Does anyone know why the evaluator that is exposed can handle general expressions, though?
My own hunch is that Excel needed to give people a way to get ranges from string addresses, and to get the value of named formulas, and just opening a portal to the expression evaluator was the easiest way. (The help for the VBA version does say its purpose it to "convert a Microsoft Excel name to an object or a value".) But of course you don't need the ability to evaluate arbitrary expressions just to do that. (That is, Excel could provide a Name.Evaluate method or something instead.)
Application.Evaluate seems kind of...unfinished. It's full behavior isn't very well documented, and there are quite a few quirks and limitations (as described by Charles Williams here: http://www.decisionmodels.com/calcsecretsh.htm) with what is exposed.
I suppose the answer could be simply "why not expose it?", but I'd be interested to know what design decisions led to this feature taking the form that it does. Failing that, I'd be interested to hear other hunches.
Well I think its required to enable VBA to get the result from a Named Formula (or a string containing a formula), (OK there is also the ugly method of inserting the formula into a spare cell and then reading back the result, but for example that won't work from inside a UDF).
In VBA its complex to determine if a Defined Name contains a range reference or a formula. Using Evaluate works for both cases.
Its also sometimes very efficient and simpler to build Excel formulae as strings and evaluate them rather than having to bring all the data from Excel into VBA and then do the calculations in VBA. (Its expensive to get data from Excel into VBA and even worse with current .NET implementations).

Resources