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: 27
Default replacing value by formula


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
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
replacing value in formula from outside worksheet? Mike[_4_] Excel Discussion (Misc queries) 4 March 24th 08 10:17 PM
help on replacing this formula Abbey Normal Excel Discussion (Misc queries) 6 August 23rd 07 05:17 PM
Replacing half a formula dpal Excel Discussion (Misc queries) 4 February 24th 07 08:43 PM
replacing varaibles in formula monika Excel Programming 1 February 26th 04 01:59 PM
Replacing a value from a formula Squid[_2_] Excel Programming 1 February 14th 04 02:02 PM


All times are GMT +1. The time now is 05:07 PM.

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"