ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Use VBA to add to existing number in cell (https://www.excelbanter.com/excel-discussion-misc-queries/58716-use-vba-add-existing-number-cell.html)

Hywel

Use VBA to add to existing number in cell
 

I am using a userform to select the data I need in certain cells.
However, if there is existing information I want to add the following
and not overwrite.

Range("C14").Select
ActiveCell.FormulaR1C1 = _
"=Sheet1!R[-2]C[6]+Sheet2!R[5]C[2]+Sheet3!R[58]C[24]"

Could anyone help,
Thanks
Hywel


--
Hywel
------------------------------------------------------------------------
Hywel's Profile: http://www.excelforum.com/member.php...o&userid=14824
View this thread: http://www.excelforum.com/showthread...hreadid=490701


Dave O

Use VBA to add to existing number in cell
 
This type of code can lead to a problem: if you take the value of the
cell and add those three other cells, what's to prevent you from
accidentally doing it again, thereby skewing your data?


JE McGimpsey

Use VBA to add to existing number in cell
 
One way:

With Range("C14")
.FormulaR1C1 = "=" & IIf(IsEmpty(.Value), "", .Value & "+") & _
"Sheet1!R[-2]C[6]+Sheet2!R[5]C[2]+Sheet3!R[58]C[24]"
End With





In article ,
Hywel wrote:

I am using a userform to select the data I need in certain cells.
However, if there is existing information I want to add the following
and not overwrite.

Range("C14").Select
ActiveCell.FormulaR1C1 = _
"=Sheet1!R[-2]C[6]+Sheet2!R[5]C[2]+Sheet3!R[58]C[24]"

Could anyone help,
Thanks
Hywel



All times are GMT +1. The time now is 01:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com