PANKAJUTEKAR
Board Regular
- Joined
- Jun 10, 2011
- Messages
- 79
Dear All,
I have tryed this code, and also i called this function in workbook event (after save event).
But still i am got any success on this.
Is one of you, sole the problem?
I totally understand the code. but still not understand how to call it.
I have tryed this code, and also i called this function in workbook event (after save event).
But still i am got any success on this.
Is one of you, sole the problem?
I totally understand the code. but still not understand how to call it.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Call SumKW
ThisWorkbook.Activate
'Dim i As Integer, j As Integer, k As Integer
'Do Until i = 112
' i = 0
' j = 3
'Cells(i, j) = Cells(7, 3)
'k = Left(cell, Len(cell) - 2)
'i = i + 1
'Loop
End Sub
Public Function SumKW(r As Range) As String
'Function will recalculate automatically
Application.Volatile
'Variables for calculations
Dim dCellKWvalue As Double, dTotal As Double
Dim cell As Range
'Sum formula in essence
For Each cell In r
dCellKWvalue = Left(cell, Len(cell) - 2)
dTotal = dTotal + dCellKWvalue
Next cell
'adding kw string to the calculated total
SumKW = dTotal & "kw"
End Function