473,395 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How do you set Accounting format in Google Script App?

Brilstern
208 100+
In the function below, I am using column H to adjust the format of column F. I would like to adjust this format to an accounting format, but I am struggling to do so. Does anyone know how to convert this string, "USD":"[Red][$$]#,##0.00", to an accounting format in the Google Script App?

Expand|Select|Wrap|Line Numbers
  1. function onEdit(e){
  2.  
  3.     var sheetName = "Debt"; //name of sheet to adjust formatting on
  4.     var currencyCol = 8; //column H
  5.     var amountCol = 6; //column F
  6.     var defaultFormat = "[$€]#,##0.00";
  7.     var currencyFormat = {"USD":"[Red][$$]#,##0.00",
  8.                           "GBP":"[Red][$£]#,##0.00",
  9.                           "EUR":"[Red][$€]#,##0.00"};
  10.  
  11.     var r = e.range;
  12.     if(e.source.getSheetName()==sheetName && r.getColumn() == currencyCol){ //edits one cell at a time
  13.       var uf = currencyFormat[r.getValue()];
  14.       uf = uf?uf:defaultFormat;
  15.       r.offset(0,amountCol-currencyCol).setNumberFormat(uf);
  16.     }
  17. }
Feb 2 '20 #1
0 3462

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: tim | last post by:
Hi, I'm playing around with the python external for PureData. (pyext) I want to enable a patch to lookup something on the net. I modified the "search.py" example from Dive Into Python and kind...
1
by: niran | last post by:
I'm transforming a XML document from client-side. The document contains placeholders for Google ADSense. But the problem is that after the transformation somehow the ads doesn't show up. All other...
6
by: shapper | last post by:
Hello, I have on my web site an Asp.Net 2.0 web.sitemap file. How can I convert it to a Google's sitemap file? Thanks, Miguel
14
by: ALaurie10 | last post by:
I have data in an excel file(s) which is in Accounting format. This means that my feilds are going down the page and the values across. Do I have to change the excel format of the data? this would be...
2
by: ALaurie10 | last post by:
I have an Excel file in Accounting Format, my field names go down the page and the data goes across. There are four values for each field. After importing my Excel file into a table, the fields are...
2
by: ALaurie10 | last post by:
I have an excel file in Accounting Format, my feild names go down the page and the data goes across. There are four values for each feild. After importing my excel file into a table, the feilds are...
10
by: Steve | last post by:
Just a warning to the group. The Google Toolbar causes Firebug to issue lots of "Too much recursion" errors in the toolbar.js and eventual causes my Firefox browser to stop responding when using...
0
by: TrevRex | last post by:
Hello, I work for a non-profit in San Diego as a GIS Specialist. I have had to teach myself about some scripting to create some dynamic maps, but I am still very limited in my skills, so I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.