Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Add value to existing cell value

Hello,

Appreciate if someone could tell me how to make the macro
add a value to a cell (from a variable). I.e. if there is
a number of 3 in cell A1 and the variable Z has a value of
2, this should generate a result of 5 in cell A1.

Thanks in advance!

Peter
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Add value to existing cell value

Something like
dim bal as variant
bal = ActiveSheet.Cells(1, 1).Value
bal = bal + Z
ActiveSheet.Cells(1,1).Value = bal

HTH
"Peter" wrote in message
...
Hello,

Appreciate if someone could tell me how to make the macro
add a value to a cell (from a variable). I.e. if there is
a number of 3 in cell A1 and the variable Z has a value of
2, this should generate a result of 5 in cell A1.

Thanks in advance!

Peter



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Add value to existing cell value

For the activecell

Sub test()
Dim z As Long
z = 3
With ActiveCell
If IsNumeric(.Value) Then
.Value = .Value + z
End If
End With
End Sub

Try this for the selection

Sub test2()
Dim z As Long
Dim cell As Range
z = 3
For Each cell In Selection
If IsNumeric(cell.Value) Then
cell.Value = cell.Value + z
End If
Next
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Peter" wrote in message ...
Hello,

Appreciate if someone could tell me how to make the macro
add a value to a cell (from a variable). I.e. if there is
a number of 3 in cell A1 and the variable Z has a value of
2, this should generate a result of 5 in cell A1.

Thanks in advance!

Peter



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing the cell format doesn't change existing cell content Kate Excel Discussion (Misc queries) 2 January 14th 10 04:44 PM
Formatting worksheets, existing and new, in existing workbooks G. Dagger[_2_] Excel Discussion (Misc queries) 4 January 7th 08 06:48 PM
Add 10% to the existing value in a cell LOOKIN FOR FORMULAS Excel Discussion (Misc queries) 6 December 4th 07 09:22 PM
Can I add 1 # to an existing # in a cell? Susan Excel Discussion (Misc queries) 1 September 18th 07 09:49 PM
download existing spreadsheets into another existing spreadsheet lbierer Excel Discussion (Misc queries) 2 September 24th 06 08:36 PM


All times are GMT +1. The time now is 10:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"