Mass replace cells with changing only specific data from their formula - google-apps-script

I have a sheet with cells that contain formulas like this:
=IF(LEN('API Tool'!P358),IF('API Tool'!P358/POWER(10,18)>=C3+(C3*25/100),"API ERROR",'API
Tool'!P358/POWER(10,18)),)
And I would like to mass replace them all and add Indirect function to C cell references like this (check the bold letters):
=IF(LEN('API Tool'!P358),IF('API Tool'!P358/POWER(10,18)>=INDIRECT("$C3")+(INDIRECT("$C3") *25/100),"API
ERROR",'API Tool'!P159/POWER(10,18)),)
Is there any script or regular expression that i could use in order to mass replace all?
Thanks

First, using a "$" symbol with INDIRECT is redundant and, in this case, is also just complicating matters. Every part of every INDIRECT reference enclosed between quotation marks is a locked reference by nature.
That said, if the changes you want to make are in a specific range only, select that range first. If they are in an entire sheet or across the entire spreadsheet, move to the next step.
Hit Ctrl-H (or Cmd-H or Edit > Find and replace) to bring up the "Find and Replace" dialog box.
In the "Find" field, enter this:
([^A-Z])(C\d+)
In the "Replace with" field, enter this:
$1INDIRECT("$2")
Make sure that you set the "Search" location to match your desired scope. (If you selected a specific range and then choose "Specific range" here, the range you currently have selected will populate.)
Check the checkboxes for "Search using regular expressions" and "Also search within formulas." This will automatically also select "Match case" (since regular expressions are case-sensitive).
Click the "Replace all" button.
The REGEX has to include (and avoid) cases where a column may incidentally include C, such as a reference to Column AC, which is why it has two parts: one that makes sure the character preceding the C is not another valid column letter and one that grabs the direct part in question.
In addition, while this is not part of what you asked, I caution you to think through why you are replacing those direct references with INDIRECT ones. It's hard to imagine a case where that would be necessary. And once you change them to INDIRECT, if you add or delete columns or rows anywhere, those references will not adjust relative to those changes — which means every one of those references will then point to the wrong place thereafter.

Related

MySQL Advanced selection of marked up data?

I have a table with spellings of words. Words are marked up in a such way:
h[e,a]llo
Where the first letter is the correct spelling, and the second is the wrong one. I need to make a selection in such a way that, for example, when "hallo" or "hello" is given, the desired word is found and passed in its original markup. Any ideas?

Excel 2016: How to select function from "suggested" dropdown list *by keyboard*?

A minor usability annoyance (or possibly ignorance):
In order to use a pre-defined function (such as SUM()) in Excel 2016 (under Win10), I type "=" (without quotation marks) into the respective cell, then the first letters of the function name, say "XY".
Thereupon, Excel opens a dropdown "suggestion" list of all functions starting with "XY".
I can select one of those by double-clicking, the full function name will be filled in, and the arguments etc. can be added.
I can also use the arrow keys to select an entry from the dropdown, but when I then hit ENTER to actually use it, the cell will display a "#NAME?" error -- correctly so, because it still only contains the string I entered ("=XY") but the rest of the function name from the list has not been inserted automatically.
How can I select and then use a function from the suggestion list by keyboard only?
Other than the obvious ENTER I have tried ctrl-ENTER, shift-ENTER, alt-ENTER, TAB, all to no avail. Web search found no results, perhaps because no one requires (or even knows about) "keyboard only" any more? :-)
Once you have highlighted the function, use the tab key

How to perform fuzzy match with Excel Add-on focusing on specific keyword

I have the Fuzzy Match extension from Microsoft that creates tables based on specified columns and provides the best match to an entry from table 1 from table X and provides a score as well. My concern is the hierarchy of keywords being matched - by that I mean, there are specific keywords that I would like the fuzzy match add-on to say "if this keyword is NOT present, do not bother attempting a fuzzy match". I also want to remove filler, such as "and" and "or" and even specific keywords that I deem irrelevant in scoring but still show up alot. Maybe I need to run a VBA script, but whatever the case, I hope someone can help me with this question.
Basically you need to clean your data before you run the Fuzzy Match on it, either manually, with formulas, with VBA, or with PowerQuery.
To do it manually, filter your data to only include terms that contain your keywords, copy and paste to a new sheet, use Find and Replace to remove " and " as well as " or " (note the spaces) in both your source data and your match data with "", and run the Fuzzy Match extension.
With formulas, you pretty much do the same thing, but using formulas to transform the Lookup column so that if it doesn't contain the keywords the formula returns =NA() and then wrap that in a couple of SUBSTITUTE functions that replace " and " as well as " or " with "", perform that last step with you lookup data, and run the Fuzzy Match extension.

Variation of SELECT * - all columns except those explicitly referenced

Is there any way to convert one column and be able to reference all the other columns without naming them explicitly?
Normally I would do this:
SELECT
,[Id]
,[Name]
,CONVERT(VARCHAR(10),[CreateDate], 104) as [CreateDate]
FROM Customers
What I could do in the perfect world would be:
SELECT
*
,CONVERT(VARCHAR(10),[CreateDate], 104) as [CreateDate]
FROM Customers
Where * would mean all columns that are not explicitly stated in the query.
Is there a keyword that enables one to do this or is there some other way? Please keep in mind that it has to be doable in a query - no changing tables, making views, SPs or something else.
There isn't a programmatic way to say "all the columns except this one" unless you wanted to build dynamic SQL from sys.columns based on a list you provide the query (it would be very difficult to derive the list of referenced columns from the query dynamically, especially as you introduce joins, where clauses, etc).
But there is a pretty trivial way to do this without typing them all. Just expand your table in Object Explorer, and drag the "Columns" node onto the query editor window. Now just remove the CreateDate column from the list.
What I like to do to avoid typing a long list of fields is select the table name in the editor and then press alt-f1. That is the same thing than typing "sp_help table". You will get a result set with all the column names of that table. I copy that list into the editor and add the commas.
An easy way to add commas at the end of all the lines by using the search and replace in the editor:
Select only the lines with the column name.
Check "Use" and select "Regular Expressions" from the drop down.
In the "Find What" type $ (Dollar sign means end of the line)
in the "Replace With" type ,
That will add a comma to the end of each selected line.
Another way is to right click on the table in the Object Explorer and click on "select top 1000" option that will create a script for you in another text editor window.

Assigning a Keyboard shortcut to a button in an Access 2007 form

Say I have a form on which a number of buttons exist. Everything works as it should when the buttons are clicked. How do I go about assigning keyboard shortcuts to my buttons so that Alt+A runs the action of Button A, Alt+B runs the action of button B etc.
seems like this would be trivial to do but I've not been able to see where I can set this.
When creating the button use the ampersand before the letter you want to Alt+? in the Caption property.
Examples:
&File ---> File
&Edit ---> Edit
F&orge --> Forge
E&nough -> Enough
If you wanted to set up a Global Keyborad Shortcut that would work no matter where you are in the current database then you can create a special macro called AutoKeys and set up like the following:
Note the special character used to represent special keys:
^ for Ctrl
+ for Shift
% for Alt
{F11} represents the F11 (function) Key
Don’t Type When Access Does it For You
[Ctrl]+[;] inserts the current date.
This is invaluable if you keep historical records, or include the date in any notes or other fields in your database. It not only saves time, but ensures data accuracy and keeps you from having to remember the date.
[Ctrl]+[:] inserts the current time.
Like the Insert Date shortcut, this feature can save more time than you realize, and it also helps to keep your data accurate.
[Ctrl]+['] inserts the value from the same field in the previous record.
When you need to enter several records consecutively, you probably find that many of the fields are the same from record to record. Using the clipboard to copy data can help, but you may need to enter several fields of duplicate information (your name in one field, the date in another field, and some generic comments in a third). Use this shortcut to insert the same field’s value from the previous record.
[Ctrl]+[Alt]+[Spacebar] inserts the default value for the current field.
This comes in handy when you start typing, and then realize that you should have kept the default.
Don’t Use the Mouse When You Can Use the Keyboard
[Ctrl]+Arrow key combinations speed up navigation
[Ctrl]+[Left/Right Arrow] moves you to the beginning of the last/next word.
[Ctrl]+[Up/Down Arrow] moves you to the beginning of the last/next paragraph.
[Shift] +Arrow key combinations select text
[Shift]+[Left/Right Arrow] selects one letter.
[Shift]+[Up/Down Arrow] selects one line.
[Ctrl]+ [Shift]+[Left/Right Arrow] selects a word.
`[Ctrl]+ [Shift]+[Up/Down Arrow] selects a paragraph.
[F2] switches between Edit mode and Navigation mode
Edit mode displays the insertion point. Navigation mode hides the insertion point, and selects the entire field. When in Navigation mode, use the arrow keys to move between fields.
[F4] opens a combo box or list box
Use this keyboard shortcut to drop down the list, and then use the arrow keys to select a value from the list.
[Ctrl]+[+] adds a new record
[Ctrl]+[-] deletes the current record
[Shift]+[Enter] saves the current record
Switching records also saves the data, but it’s a good idea to save frequently, especially if you’re entering a lot of data.
[Ctrl]+[PgUp] goes to the previous record
[Ctrl]+[PgDn] goes to the next record
If you want to add Function keys as shortcut to the forms, Add the below code to your form VB Code.
Need to set KeyPreview to Yes in order to work (see image below)
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF5
'Process F5 key events.
Msgbox "F5"
Case vbKeyF4
' Process F4 key events.
MsgBox "F4"
Case Else
End Select
End Sub