title: Cannot VBA write data to cells in Excel 2007/2010 within a function
body: <p>I want to set value for cells by VBA. I have googled, and see some resolution:</p>
  
  <pre><code>Sheets("SheetName").Range("A1").value = someValue
  Sheets("SheetName").Cells(1,1).value = someValue
  </code></pre>
  
  <p>With this kind of code, I can just read data from cell A1 but I cannot set a new value to it. </p>
  
  <p><em>Update</em></p>
  
  <p>The code to set cell A1 value is put within a <code>Function</code> as below.</p>
  
  <pre><code>Function abb()
      Sheets("SheetName").Range("A1").value = 122333
      abb = 'any thing'
  End Function
  </code></pre>
  
  <p>In cell B2, I set <code>=abb()</code> and hit enter. I get #VALUE but nothing happen at A1.</p>
  
  <p>Putting this code in a macro, it works.</p>
  
  <p>My question is, how to make A1 have values within a function?</p>