S
sermest
Hi I have below functions. I did not get what is mismatching. Can
anybody help? Thanks,
Function TYLY() As Integer
Dim FFW, LHW, FDate As Date
Dim FWRow, HWRow, HWColumn, FP, HP As Integer
Dim DateRange, FWCell, HWCell As Range
FFW = Worksheets("F").Cells(22, 49).Value
FP = Worksheets("F").Cells(23, 49).Value
LHW = Worksheets("F").Cells(25, 49).Value
HP = Worksheets("F").Cells(26, 49).Value
Set DateRange = Worksheets("F").Range("F:F")
Set FWCell = DateRange.Find(DateValue(FFW), ,
LookIn:=xlFormulas)
Set HWCell = DateRange.Find(DateValue(LHW), ,
LookIn:=xlFormulas)
FWRow = FWCell.Row
HWRow = HWCell.Row
HWColumn = HWCell.Column
......
With Cells(y, 38)
.Font.ColorIndex = 52
.Value = TValue(HWRow, HP, 7, FWRow)
.Interior.ColorIndex = 6
.......
The TValue function that I call above is below:
Function TValue(THWRow, THP, TDColumn, TFWRow As Integer) As Long
Dim TTY, TLY As Double
TValue = 0
TTY = 0
TLY = 0
For x = THWRow - THP + 1 To THWRow
TTY = TTY + Cells(x, TDColumn).Value
Next x
For y = THWRow - THP + 1 - 52 To THWRow - 52
TLY = TLY + Cells(x, TDColumn).Value
Next y
TValue = (TTY / TLY) * Cells(TFWRow, TDColumn)
End Function
anybody help? Thanks,
Function TYLY() As Integer
Dim FFW, LHW, FDate As Date
Dim FWRow, HWRow, HWColumn, FP, HP As Integer
Dim DateRange, FWCell, HWCell As Range
FFW = Worksheets("F").Cells(22, 49).Value
FP = Worksheets("F").Cells(23, 49).Value
LHW = Worksheets("F").Cells(25, 49).Value
HP = Worksheets("F").Cells(26, 49).Value
Set DateRange = Worksheets("F").Range("F:F")
Set FWCell = DateRange.Find(DateValue(FFW), ,
LookIn:=xlFormulas)
Set HWCell = DateRange.Find(DateValue(LHW), ,
LookIn:=xlFormulas)
FWRow = FWCell.Row
HWRow = HWCell.Row
HWColumn = HWCell.Column
......
With Cells(y, 38)
.Font.ColorIndex = 52
.Value = TValue(HWRow, HP, 7, FWRow)
.Interior.ColorIndex = 6
.......
The TValue function that I call above is below:
Function TValue(THWRow, THP, TDColumn, TFWRow As Integer) As Long
Dim TTY, TLY As Double
TValue = 0
TTY = 0
TLY = 0
For x = THWRow - THP + 1 To THWRow
TTY = TTY + Cells(x, TDColumn).Value
Next x
For y = THWRow - THP + 1 - 52 To THWRow - 52
TLY = TLY + Cells(x, TDColumn).Value
Next y
TValue = (TTY / TLY) * Cells(TFWRow, TDColumn)
End Function