View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
merjet merjet is offline
external usenet poster
 
Posts: 812
Default Calculating revenue over fiscal quarters

Assume your data is in columns A-F of Sheet1. In row 1, starting in
column H, put Q3FY07, Q4FY07, etc. Then the following macro will
generate the revenues by quarter and contract. If you want revenue by
client and quarter, you can use the worksheet function SUMIF below the
macro's output.

Sub RevByQtr()
Dim iRow As Integer
Dim iCol As Integer
Dim ws As Worksheet
Dim bFlag As Boolean
Set ws = Sheets("Sheet1")
iRow = 2
Do
iCol = 8
Do
If Left(ws.Cells(iRow, 3), 2) = Left(ws.Cells(1, iCol), 2) And _
Right(ws.Cells(iRow, 3), 2) = Right(ws.Cells(1, iCol), 2) Then
bFlag = True
For iCt = 1 To ws.Cells(iRow, 5) / 3
ws.Cells(iRow, iCol + iCt - 1) = ws.Cells(iRow, 6)
Next iCt
End If
iCol = iCol + 1
Loop Until bFlag = True
bFlag = False
iRow = iRow + 1
Loop Until ws.Cells(iRow, 2) = ""
End Sub

Hth,
Merjet