rizwan_planning
New Member
- Joined
- Nov 23, 2013
- Messages
- 8
hello all
good morning,
i am new to VBA
I want to genrate vba based on precent complete.
Let consider we have two cells C12 (done quantity) & D12(budget quantity)
E12=C12/D12
at start E12 is 0
if c12 is changed then A12 should reflact the date on which E12 become greater than 0
similarly B12 should reflact the date on which E12 become 100%
I had genrated the code
-------------
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rCell As Range
Dim rChange As Range
Dim lastrow As Long
Dim c As Range, rng As Range
'change Sheet1 to suit
On Error GoTo ErrHandler
With ThisWorkbook.Worksheets("Sheet2")
lastrow = .Cells(.Rows.Count, "C").End(xlUp).Row
For Each c In .Range("C1:C" & lastrow)
If UCase(c.Text) = "FALSE" Then
If rng Is Nothing Then
Set rng = .Range("C" & c.Row).Resize(, 20)
Else
Set rng = Union(rng, .Range("C" & c.Row).Resize(, 20))
End If
End If
Next c
End With
Set rChange = Intersect(Target, rng)
If Not rChange Is Nothing Then
Application.EnableEvents = False
For Each rCell In rChange
If rCell = "0" Then
If rCell > "0.1" Then
With rCell.Offset(0, 1)
.Value = Now
.NumberFormat = "hh:mm:ss"
End With
Else
rCell.Offset(-1, 1).Clear
End If
End If
Next
End If
ExitHandler:
Set rCell = Nothing
Set rChange = Nothing
Application.EnableEvents = True
Exit Sub
ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub
------------------------
i need the logic for this section
If rCell = "0" Then
If rCell > "0.1" Then
With rCell.Offset(0, 1)
.Value = Now
.NumberFormat = "hh:mm:ss"
End With
Else
rCell.Offset(-1, 1).Clear
End If
End If
Next
please help me
Thanks in advance
regards
R khan
good morning,
i am new to VBA
I want to genrate vba based on precent complete.
Let consider we have two cells C12 (done quantity) & D12(budget quantity)
E12=C12/D12
at start E12 is 0
if c12 is changed then A12 should reflact the date on which E12 become greater than 0
similarly B12 should reflact the date on which E12 become 100%
I had genrated the code
-------------
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rCell As Range
Dim rChange As Range
Dim lastrow As Long
Dim c As Range, rng As Range
'change Sheet1 to suit
On Error GoTo ErrHandler
With ThisWorkbook.Worksheets("Sheet2")
lastrow = .Cells(.Rows.Count, "C").End(xlUp).Row
For Each c In .Range("C1:C" & lastrow)
If UCase(c.Text) = "FALSE" Then
If rng Is Nothing Then
Set rng = .Range("C" & c.Row).Resize(, 20)
Else
Set rng = Union(rng, .Range("C" & c.Row).Resize(, 20))
End If
End If
Next c
End With
Set rChange = Intersect(Target, rng)
If Not rChange Is Nothing Then
Application.EnableEvents = False
For Each rCell In rChange
If rCell = "0" Then
If rCell > "0.1" Then
With rCell.Offset(0, 1)
.Value = Now
.NumberFormat = "hh:mm:ss"
End With
Else
rCell.Offset(-1, 1).Clear
End If
End If
Next
End If
ExitHandler:
Set rCell = Nothing
Set rChange = Nothing
Application.EnableEvents = True
Exit Sub
ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub
------------------------
i need the logic for this section
If rCell = "0" Then
If rCell > "0.1" Then
With rCell.Offset(0, 1)
.Value = Now
.NumberFormat = "hh:mm:ss"
End With
Else
rCell.Offset(-1, 1).Clear
End If
End If
Next
please help me
Thanks in advance
regards
R khan