brigitte,
all steps but the last one.
add the following routines to the worksheet Data
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 Then
Application.EnableEvents = False
Call ChangedPublishDate(Target)
Application.EnableEvents = True
ElseIf Target.Column = 4 Then
Application.EnableEvents = False
Call ChangedEstimate(Target)
Application.EnableEvents = True
ElseIf Target.Column = 7 Then
If Target.Value = "Complete" Then
Application.EnableEvents = False
Call CompleteProject(Target)
Application.EnableEvents = True
End If
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 2 Then
pubCellBValue = ActiveCell.Value
ElseIf Target.Column = 4 Then
pubCellDValue = ActiveCell.Value
End If
End Sub
create a new module, and insert the following code
Option Explicit
'#
'# declare a public variable that holds the content of the cells in the B and D columns when the user moves the
'# cursor to either column to make a change - the value in either variable is updated by a worksheet_selection_change
'# event
'#
Public pubCellBValue As String
Public pubCellDValue As Long
'##################################################################################################
'# routine to process changes made to the published date shown in column B - this routine is triggered by the
'# worksheet_change event in case of a change made to any cell in column B
'##################################################################################################
Public Sub ChangedPublishDate(ByRef rngTarget As Excel.Range)
'#
'# declare
'#
Dim intTextLength As Integer
'#
'# if the public variable pubCellBvalue holds a value then this value represents the previous value
'# held in the cell before a user made a change - this value must be appended to the value in column
'# C for the current row
'#
If LenB(pubCellBValue & "") > 0 Then
intTextLength = Len(ActiveSheet.Cells(rngTarget.Row, "C").Value)
ActiveSheet.Cells(rngTarget.Row, "C").Value = ActiveSheet.Cells(rngTarget.Row, "C").Value & vbLf & pubCellBValue
ActiveSheet.Cells(rngTarget.Row, "C").Characters(intTextLength + 1, Len(pubCellBValue)).Font.Strikethrough = True
pubCellBValue = vbNullString
End If
End Sub
'##################################################################################################
'# routine to process changes made to the estimate shown in column D - this routine is triggered by the
'# worksheet_change event in case of a change made to any cell in column D
'##################################################################################################
Public Sub ChangedEstimate(ByRef rngTarget As Excel.Range)
'#
'# declare
'#
Dim intTextLength As Integer
'#
'# if the public variable pubCellBvalue holds a value then this value represents the previous value
'# held in the cell before a user made a change - this value must be appended to the value in column
'# C for the current row
'#
If pubCellDValue > 0 Then
intTextLength = Len(ActiveSheet.Cells(rngTarget.Row, "E").Value)
ActiveSheet.Cells(rngTarget.Row, "E").Value = ActiveSheet.Cells(rngTarget.Row, "E").Value & vbLf & pubCellDValue
ActiveSheet.Cells(rngTarget.Row, "E").Characters(intTextLength + 1, Len(pubCellDValue)).Font.Strikethrough = True
pubCellDValue = 0
End If
End Sub
'##################################################################################################
'# routine to process a project being reported as complete - this routine is triggered by the
'# worksheet_change event in case of a change made to any cell in column G where the selected value equals 'Complete'
'##################################################################################################
Public Sub CompleteProject(ByRef rngTarget As Excel.Range)
'#
'# declare
'#
Dim strCompletionDate As String
'#
'# prompt the user for a completion date
'#
strCompletionDate = Application.InputBox("Please specifiy completion date", "Complete", Format$(Now(), "dd/mm/yyyy"), , , , , 2)
If Not IsDate(strCompletionDate) Then
MsgBox "No valid date provided"
End If
'#
'# store the completion date
'#
rngTarget.Offset(, 2).Value = DateValue(strCompletionDate)
'#
'# move the row onto the complete worksheet
'#
rngTarget.Parent.Rows(rngTarget.Row).Copy ThisWorkbook.Worksheets("Complete").Cells(Rows.Count, "A").End(xlUp).Offset(1)
rngTarget.Parent.Rows(rngTarget.Row).Delete
End Sub
Bookmarks