From: Don Guillett on
Sub makeformula()
For i = 2 To 22
Cells(i, "d").Value = Cells(i, "e") + Cells(i, "f")
Next i
Columns("e:f").clearcontents 'Delete
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett(a)gmail.com
"Kristen" <Kristen(a)discussions.microsoft.com> wrote in message
news:D8442729-E1AF-418D-A3AE-5688FB424131(a)microsoft.com...
> Hi Tom,
> Thanks for answering my question. I get a "Compile Error Invalid outside
> procedure" error when I tried this. Yes, the formula method would work,
> however, I also need to delete the contents of columns E and F while
> keeping
> the added values.
>
> "tompl" wrote:
>
>> It seems that one option would be to put the formula = E1 + F1 in cell
>> D1.
>> But maybe that is not what you want in which case you could use this
>> routine:
>>
>> Sub testing()
>>
>> Dim lng As Long
>>
>> For lng = 1 To 500
>> Range("D" & lng).Value = Range("E" & lng).Value _
>> + Range("F" & lng).Value
>> Next lng
>>
>> End Sub
>>
>> Tom (is my name not part of code)

From: tompl on
I don't know why you get the compile error, maybe it is a 2007 issue as I run
excel 2003. I have added the code to clear the contents of columns D & F
here, but you might want to try Don Guillett's code.


Sub testing()

Dim lng As Long

For lng = 1 To 100
Range("D" & lng).Value = Range("E" & lng).Value + Range("F" & lng).Value
Range("E" & lng, "F" & lng).ClearContents
Next lng

End Sub