LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Worksheet_Change help please

My spreadsheet is tracking budget vs acutals for various stages in a project.
Column E stores the Project stage, Initiation, Planning and Execution.
Columns H through J store original budget, revised budget and actual for the
Initiation Stage, Columns K through M store original budget, revised budget
and actual for the Planning stage, Columns N through P store original budget,
revised budget and actual for the Execution Stage, Column Q remaining budget
and the grand total is stored in Column S.

Depending on what is selected in Column E, the total (column S) is updated.

This is the code

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range

Set rng = Intersect(Target, Range("E:E"))

If Not rng Is Nothing Then
On Error GoTo XIT
Application.EnableEvents = False
With rng
Select Case (.Value)
Case "Initiation":
'if there is a value in the revised budget column (4) use it
and add any remaining budget column (12) to the total
'otherwise use the original budget column (3) + any
remaining budget column (12)
If .Offset(0, 4).Value 0 Then
.Offset(0, 13).Value = .Offset(0, 4).Value + .Offset(0,
12).Value
Else
.Offset(0, 13).Value = .Offset(0, 3).Value + .Offset(0,
12).Value
End If
Case "Planning":
'if there is a value in the revised budget for planning
column (7) use it as well as the actual cost
'for the previous stage column (5) Plus any remaining
budgetcolumn (12) in the total column (13)
If .Offset(0, 7).Value 0 Then
.Offset(0, 13).Value = .Offset(0, 5).Value + .Offset(0,
7).Value + .Offset(0, 12).Value
Else
.Offset(0, 13).Value = .Offset(0, 5).Value + .Offset(0,
6).Value + .Offset(0, 12).Value
End If
Case "Execution":
'if there is a value in the revised budget for execution
column use it as well as the actual cost
'for the previous stage(s) in the total
If .Offset(0, 10).Value 0 Then
.Offset(0, 13).Value = .Offset(0, 5).Value + .Offset(0,
8).Value + .Offset(0, 10).Value + .Offset(0, 12).Value
Else
.Offset(0, 13).Value = .Offset(0, 5).Value + .Offset(0,
8).Value + .Offset(0, 9).Value + .Offset(0, 12).Value
End If
Case Else:
'do nothing. Allow the entry in the E column but don't
bother with any other updates
End Select
End With
End If

XIT:
Application.EnableEvents = True

End Sub

-------------------------------------------------------------------
This works great.

Problem is, if I make any updates in any of the Columns H through Q, I have
to reselect Column E of the same row to get the code to fire.

I'm not quite sure how to update my code to have it trigger if any changes
occur in the Columns H through Q (as well as E) and then evaluate whats in
Column E and do the appropriate Calculation for the total budget.

Any guidance would be greatly appreciated.

Thanks




 
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
Worksheet_Change noname Excel Programming 2 August 2nd 07 02:45 PM
Worksheet_Change Little Penny Excel Programming 6 December 1st 06 06:29 PM
worksheet_change vs. calculate, and worksheet_change not running Tom Ogilvy Excel Programming 1 July 14th 03 02:51 AM
worksheet_change vs. calculate, and worksheet_change not running Ross[_5_] Excel Programming 0 July 13th 03 04:27 PM


All times are GMT +1. The time now is 08:19 AM.

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

About Us

"It's about Microsoft Excel"