title: How to get Row & Column values from A1Notation
body: <p>Writing scripts for Google Spreadsheets can be difficult sometimes, because the Google Spreadsheet methods that take row and column numbers use 1-based indexing, while Javascript arrays use 0-based.</p>
  
  <p><img src="https://i.stack.imgur.com/RnLRn.png" alt="screenshot"></p>
  
  <p>In this example, cell <code>A2</code> has a <code>row == 2</code> and <code>column == 1</code>. The SpreadsheetApp methods reverse column &amp; row from those in A1Notation, so these two ranges are equivalent:</p>
  
  <pre><code>var range1 = sheet.getRange("A2");
  var range2 = sheet.getRange(2, 1);
  </code></pre>
  
  <p>Once I read the contents of a sheet into an array, things are different again.</p>
  
  
  
  <pre class="lang-js prettyprint-override"><code>var ss = SpreadsheetApp.getActive();
  var sheet = ss.getActiveSheet();
  var data = sheet.getDataRange().getValues();
  </code></pre>
  
  <p>After that, the value that was in cell <code>A2</code> in my spreadsheet is in <code>data[1][0]</code>. The row &amp; column are in the same order as the SpreadsheetApp API, but each is 1 less.</p>
  
  <p><img src="https://i.stack.imgur.com/i5Zkr.png" alt="screenshot 2"></p>
  
  <p>The answers to lots of questions here (<a href="https://stackoverflow.com/search?q=%5Bgoogle-apps-script%5D+array+zero">example</a>) have boiled down to mismatching of these different forms of indexing. Code that is full of <code>row+1</code> and <code>col-1</code> statements can be hard to debug. </p>
  
  <p><strong>Finally:</strong> If I know the reference for a cell in A1Notation, say <code>AZ342</code>, how can I find out the correct index values correspond to that cell in the 2D array, <code>data</code>, obtained from the full Data Range?</p>