Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Creating a Button to add to existing values while subtracting range
Greetings Programers,
I have be looking for some samples of how to use a button with a macro to add a value (let's say minutes) entered in cell A1. Which upon clicking the button adds the value in A1 to an existing value of (mins.) to cell A2. Once the total in A2 is updated, range (A3:F3) of positive values are subtracted and the results are displayed in cell B1(Mins. remaining). I know this should be a simple one. But being new to VB, I need some help on this one. I thought I saw an example of this somewhere but can't locate it. Thank in advance, Chris A. Z. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Creating a Button to add to existing values while subtracting range
Hi Chris,
Off the top Private Sub CommandButton1_Click() Dim cell As Range Range("A2").Value = Range("A1").Value Range("B1").Value = Range("A2").Value For Each cell in Range("A3:F3") If cell.Value 0 Then Range("B1").Value = Range("B1").Value - cell.Value End If Next cell End Sub But why not just do it with worksheet formula? -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "C. A. Zan" wrote in message ... Greetings Programers, I have be looking for some samples of how to use a button with a macro to add a value (let's say minutes) entered in cell A1. Which upon clicking the button adds the value in A1 to an existing value of (mins.) to cell A2. Once the total in A2 is updated, range (A3:F3) of positive values are subtracted and the results are displayed in cell B1(Mins. remaining). I know this should be a simple one. But being new to VB, I need some help on this one. I thought I saw an example of this somewhere but can't locate it. Thank in advance, Chris A. Z |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Subtracting two cells-one has existing formula???? | Excel Discussion (Misc queries) | |||
creating a range reference from cell values | Excel Discussion (Misc queries) | |||
Creating an column of values from an existing array | New Users to Excel | |||
Creating an EXCEL COUNTIF formula for a range of values | Excel Discussion (Misc queries) | |||
Creating new worksheet from existing | Excel Discussion (Misc queries) |