Calculation help

  • Thread starter Thread starter radio operator
  • Start date Start date
R

radio operator

Need some help please.

Excel spreadsheet..

Cell A1 has 100 in it
Cell B1 has 12 in it

Need to figure out a way of adding A1 + B1 and putting the resultin
figure into
cell A1, and deleting the contents of B1.

Hope you can help me on this.

Many Thanks

Radio Operator

:confused
 
Need some help please.

Excel spreadsheet..

Cell A1 has 100 in it
Cell B1 has 12 in it

Need to figure out a way of adding A1 + B1 and putting the resulting
figure into
cell A1, and deleting the contents of B1.

Hope you can help me on this.

Many Thanks

Radio Operator

:confused:

You need to use VBA to do this.

<alt><F11> opens the VB Editor.

Ensure your project is highlighted in the project explorer window, then
Insert/Module and paste the code below into the window that opens.

============================
Sub AddA1B1()
If IsNumeric([a1]) And IsNumeric([b1]) Then
[a1].Value = [a1].Value + [b1].Value
[b1].ClearContents
End If
End Sub
=============================

Enter data into A1 & B1 and then run the macro:

<alt><F8> opens the macro dialog box. Select AddA1B1 and Run.

Or you can attach the macro to a button.




--ron
 
Ron,
Thanks for the help on the last one, it works great.

I would like to run multiple macro's at the same time,
is there an easy command to do this. It's the same
calculation as below, only repeated over the entire
column (About 45 macro's).

Many Thanks again for all your help

Stephen McArthur
 
Ron,
Thanks for the help on the last one, it works great.

I would like to run multiple macro's at the same time,
is there an easy command to do this. It's the same
calculation as below, only repeated over the entire
column (About 45 macro's).

Many Thanks again for all your help

Stephen McArthur

I've not checked this out for possible errors, but something like:

===========================
Sub AddAB()
dim c as range
dim aoi as range

set aoi = [a1:a45]

for each c in aoi

If IsNumeric(c.value) And IsNumeric(c.offset(0,1).value) Then
c.Value = c.Value + c.offset(0,1).Value
c.offset(0,1).ClearContents
End If

next c

End Sub
=========================


--ron
 
Back
Top