Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Summation of the Cells

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
a_k93 - 23 Mar 2006 16:35 GMT
Hi there,

I want to sum up the value of the cell A1, A2, A3 and A4 in cell C1
this is done,
by the following
In the Worksheet_change Event
c1.value = application.worksheetfunction.sum(a1,a2,a3,a4)

User is allowed to enter value in c1 cell directly. If user enter
value in C1 cell directly, at

that time I want the Cell A1, A2, A3 and A4 should become 0.
Again if the user enters in any of the cells (a1, a2, a3, a4) then c
value should get

overwritten by the summation of the 4 cells.

your help is appreciated
thanx in advance,
a_k9
Jim Thomlinson - 23 Mar 2006 17:06 GMT
In the sheet itself place this code (Right click the sheet tab and select
view code)

Private Sub Worksheet_Change(ByVal Target As Range)
   On Error GoTo ErrorHandler
   Application.EnableEvents = False
   If Not (Intersect(Target, Range("A1:A4")) Is Nothing) Then
       Range("C1").Value = Application.Sum(Range("A1:A4"))
   ElseIf Target.Address = "$C$1" Then
       Range("A1:A4").Value = 0
   End If
ErrorHandler:
   Application.EnableEvents = True
End Sub

Signature

HTH...

Jim Thomlinson

> Hi there,
>
[quoted text clipped - 16 lines]
> thanx in advance,
> a_k93
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.