Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() HI, My column heading (Y9:AF9) a Mar-04 Apr-04 May-04 Jun-04 Q4 2004 Q1 2005 Year 2004 Sum Year 2005 Sum I have to have a YEar SUm of 2004 and 2005, which i am doing by the code below. With this logic i am getting the final value and formala. Instead of this logic I want to have =SUM(Y10:AC10) in each cell. Before having a total I want to check whether it lies in 2004 or 2005. IS it possible to replace the cell value by the formula as =SUM(Y10:AC10)? thanks in advance monika 'INSERTING VALUES FOR YEARLY SUM'S COLUMNS Dim sysYr, fSumYr1, fSumYr2 As Long Dim QYR As Long sysYr = Year(Date) j = LNewRng.Row + 1 k = LNewRng.Row While j <= LastCellNum i = lastCol + 1 'REINITIALIZING FOR EVERY NEW ROW fSumYr1 = 0 'REINITIALIZING FOR EVERY NEW ROW fSumYr2 = 0 'REINITIALIZING FOR EVERY NEW ROW While i <= colEnd If IsDate(Cells(k, i).Value) = True Then 'SUM FOR DATE CASES yr1 = Year(Cells(k, i).Value) If yr1 = sysYr Then fSumYr1 = fSumYr1 + Cells(j, i).Value Else 'Stop fSumYr2 = fSumYr2 + Cells(j, i).Value End If ElseIf Mid(Cells(k, i).Value, 1, 1) = "Q" Then 'QUARTER SUM CALCULATION QYR = Right(Cells(k, i).Value, 4) If QYR = sysYr Then fSumYr1 = fSumYr1 + Cells(j, i).Value Else fSumYr2 = fSumYr2 + Cells(j, i).Value End If End If i = i + 1 Wend Cells(j, colEnd).Value = fSumYr1 Cells(j, colEnd + 1).Value = fSumYr2 j = j + 1 Wend |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
replacing value in formula from outside worksheet? | Excel Discussion (Misc queries) | |||
help on replacing this formula | Excel Discussion (Misc queries) | |||
Replacing half a formula | Excel Discussion (Misc queries) | |||
replacing varaibles in formula | Excel Programming | |||
Replacing a value from a formula | Excel Programming |