Combining valueRenderOptions in spreadsheets.values.get - google-sheets-api

When using spreadsheets.values.get, there does not seem to be a way to combine valueRenderOptions.
The reason for doing this would be to use both FORMULA and UNFORMATTED_VALUE at the same time.
FORMULA does not preserve escaped strings. I would like to have both options specified so that my strings come back to me escaped and my formulas come back unresolved.

Related

Does regex not work in Excel search?

I am trying to search for trailing whitespaces in text cells in Excel. Knowing that Excel search accepts regex, I expected to leverage on the full feature set, but was surprised to find that some features do not seem to work.
For example, I have some cells with strings like ELUFA\s\s\s\s\s (note: in my excel sheet there is no \s, but just blank invisible whitespaces, after ELUFA, but I had to add these \s in here otherwise Stackoverflow would just remove these whitespaces and the string would just appear to be ELUFA) or NATION CONFEC.\s with trailing whitespaces.
I used the expression [A-Z.]{1}\s+$ into the excel search function expecting that it would return search results for these cells, but it does not, and just tells me that nothing is found.
However, what I find really funny is that Excel search is somehow able to interpret a regex like this A *. Using this expression, excel search does find for me only the ELUFA\s\s\s\s\s cells, and no other cells which do not match this regex.
Is there some kind of limitations as to what subset of the full REGEX that Excel search accepts? How do we get excel search to accept the full REGEX feature set as described here?
Thank you.
The Excel SEARCH() function does not support full regex. It actually only supports two wildcards, ? and *. From the documentation:
You can use the wildcard characters — the question mark (?) and asterisk (*) — in the find_text argument. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) before the character.
If you want to match spaces then you will have to enter them as literals. Note that finding any amount of trailing spaces could be as simple as ELUFA\s, with one space at the end, because that would actually match one, or more than one, space.

How to Translaste this =SUM(COUNTIFS(F4:AN4,{"0","1"})) into VBA?

I need help translating a common Excel function, into VBA code.
Please see attached screenshot for the code I already have started.
I am using the calculations seen in the screenshot to build a scorecard/grading worksheet. I will need to adjust the rows in each of these, but never the columns.
Once I figure this out, I will then loop these to repeat for each new row as they are added.
image of my code, so far
When a literal string needs to contain double-quote characters, you need to use two double-quotes in a row for each double-quote you need in the string.
So your string
Range("AP4").Formula = "SUM(COUNTIFS(J3:AR3,{"0","1"}))"
needs to look like this:
Range("AP4").Formula = "SUM(COUNTIFS(J3:AR3,{"“0"”,""1""}))"
You can also do this without putting the formula into the content of the cell like this:
Range("AP4") = WorksheetFunction.SUM(WorksheetFunction.COUNTIFS(J3:AR3,{""0"",""1""}))

How can I disable automatic string detection in VS2015?

I'm using VB.NET, and my code contains a lot of strings that very often have double quotes inside of them. My problem is that as I'm fixing the string to escape double quotes (replacing every '"' with '""' inside of the string) it messes with the proceeding code, temporarily assuming everything is a string (since the double quotes don't match up) and completely messing up the formatting of other strings. It assumes that the start of a following string is the end of the current string which causes the actual string to be interpreted and formatted as code, which I have to go back and fix (since it adds spaces and other formatting characters that shouldn't actually be there).
Is there any way to disable this behavior? I didn't have the same problem in VS2013. I've been looking under Tools > Options > Text Editor > Basic, but I couldn't find anything relevant.
Additional Information: I can just modify the strings in a separate text document to escape all of the double-quotes (which is what I've resorted to for now), but in VS2013 I could easily just copy/paste the strings directly into my code without it messing up proceeding strings by temporarily interpreting them as code due to the uneven count of double-quotes.
This behavior is especially problematic when manually adding double-quotes within strings, because if you don't escape them quickly enough (or make a brief typo when doing so), you get the same issue.
You might notice that for other languages, such as C++, writing a string on one line (even with an uneven number of double-quotes) does not affect proceeding lines. Having this same behavior for VB would be great, assuming that there's some setting to enable it.
Yes its an inconvenience.
What I usually do is put some non-used character (e.g. some unused symbol on keyboard, or Alt+{some number}) instead of double quotes. When I'm done building my string whatever way I want, I just finalize it with either bringing up the Find and Replace box and replace that character with two double-quotes. Or just put a REPLACE statement immediately following it, replacing that character with Chr(34).
Instead use Chr(34), or if you end up repeating strings at all, store them as a resource.

VBA texttocolumns ignores one column

I have data that was previously improted into Excel and want to have that data automatically put into the proper format.
Right now my dates look like this: 28122012 which should be 28.12.2012
My code, which I've put together with some sources I've found online, works well except for one snag... it ignores column V:
Dim rngS As Range
For Each rngS In .Range("F:F,U:W").Columns
rngS.TextToColumns Destination:=rngS.Cells(1, 1), _
DataType:=xlFixedWidth, FieldInfo:=Array(0, 4)
Next
I'm not certain why it does this. I've experimented by writing out each column, but no go. Column V remains as it is, while everything around it gets properly formatted.
Any ideas why this could be?
Thanks!
The problem is the field it pastes to is treating the value as numerical.
The only real remedy is to set the type to Text for that and other columns that might have such a date value. Then 01122012 will not lose its starting zero.
Alternatively you could let your follow up code or formula anticipate the missing zeroes and work back to date values using LEFT(), RIGHT() and like functions.

Range(...).Formula does not translate fully

I cannot figure this one out.
We use mostly french-version Excel (as we live in a french-speaking province of Canada). Somewhere in VBA code I set a cell's formula directly. Normally, we have to write the formula in english and Excel does the translation (writing the formula in any other language than english in VBA results in an error as far as I know). However, only HALF of this equation is translated which I think is causing me issues (writing the correct formula in another cell yields different results and most probably right results).
range("J2").Formula = "=round(IF(F2="",0,F2),2)-round(IF(G2="",0,G2),2)"
Is translated to this in the cell:
=ARRONDI(SI(F2=",0,F2),2)-round(IF(G2=",0,G2),2)
As you can see, the right part should read "ARRONDI(SI(.." but it does not read that way. I have tried adding spaces, removing the minus sign altogether, etc. Nothing works, it's always half translated. Any idea ?
In VBA you neexd to escape your quotations like this:
range("J2").Formula = "=round(IF(F2="""",0,F2),2)-round(IF(G2="""",0,G2),2)"
This is because the " Character is used in VBA as the start / end of a string. So if you want ot include it IN a string you need to type it twice in a row.