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: 70
Default application.worksheetfunction

Hello,
I am using a Vlookup and a sumif function in loops... when I gor through the
sub via F8 the calculation is correct but when I execute at once with F5 I
get a incorrect answer... I have to find a solution to this.
Here is a sample of it:
(I tried everything I know please aby help would be appreciated greatly)

For i = 4 To 500
If Sheets("DLF").Range("A" & i) = "" Then
Exit For
Else
TMC_BEG_INV_QTY = Sheets("DLF").Cells(i, 3).Value
TMC_BEG_INV_AMT = Sheets("DLF").Cells(i, 4).Value
TMC_PURCHASE_QTY = Sheets("DLF").Cells(i, 5).Value
TMC_PURCHASE_AMT = Sheets("DLF").Cells(i, 6).Value
TMC_USAGE_QTY = Sheets("DLF").Cells(i, 8).Value
If (TMC_BEG_INV_QTY + TMC_PURCHASE_QTY) = 0 Then
TMC_USAGE_AMT = 0
TMC_USAGE_MAC = 0
Sheets("DLF").Cells(i, 9) = TMC_USAGE_AMT
Sheets("DLF").Cells(i, 7) = TMC_USAGE_MAC
Else
TMC_USAGE_AMT = (TMC_BEG_INV_AMT + TMC_PURCHASE_AMT) /
(TMC_BEG_INV_QTY + TMC_PURCHASE_QTY) * TMC_USAGE_QTY
Sheets("DLF").Cells(i, 9) = TMC_USAGE_AMT
TMC_USAGE_MAC = (TMC_BEG_INV_AMT + TMC_PURCHASE_AMT) /
(TMC_BEG_INV_QTY + TMC_PURCHASE_QTY)
Sheets("DLF").Cells(i, 7) = TMC_USAGE_MAC
End If
End If
Next
TMC_BEG_INV_QTY = 0
TMC_BEG_INV_AMT = 0
TMC_PURCHASE_QTY = 0
TMC_PURCHASE_AMT = 0
TMC_USAGE_QTY = 0
TMC_USAGE_AMT = 0
TMC_USAGE_MAC = 0
Call DLF_USAGE_AMT_FEBCY
End Sub

Sub DLF_USAGE_AMT_FEBCY()
'FebCY
For i = 4 To 500
If Sheets("DLF").Range("A" & i) = "" Then
Exit For
Else
TMC_BEG_INV_QTY = Sheets("DLF").Cells(i, 12).Value
TMC_BEG_INV_AMT = Sheets("DLF").Cells(i, 13).Value
TMC_PURCHASE_QTY = Sheets("DLF").Cells(i, 14).Value
TMC_PURCHASE_AMT = Sheets("DLF").Cells(i, 15).Value
TMC_USAGE_QTY = Sheets("DLF").Cells(i, 17).Value
If (TMC_BEG_INV_QTY + TMC_PURCHASE_QTY) = 0 Then
TMC_USAGE_AMT = 0
TMC_USAGE_MAC = 0
Sheets("DLF").Cells(i, 18) = TMC_USAGE_AMT
Sheets("DLF").Cells(i, 16) = TMC_USAGE_MAC
Else
TMC_USAGE_AMT = (TMC_BEG_INV_AMT + TMC_PURCHASE_AMT) /
(TMC_BEG_INV_QTY + TMC_PURCHASE_QTY) * TMC_USAGE_QTY
Sheets("DLF").Cells(i, 18) = TMC_USAGE_AMT
TMC_USAGE_MAC = (TMC_BEG_INV_AMT + TMC_PURCHASE_AMT) /
(TMC_BEG_INV_QTY + TMC_PURCHASE_QTY)
Sheets("DLF").Cells(i, 16) = TMC_USAGE_MAC
End If
End If
Next
TMC_BEG_INV_QTY = 0
TMC_BEG_INV_AMT = 0
TMC_PURCHASE_QTY = 0
TMC_PURCHASE_AMT = 0
TMC_USAGE_QTY = 0
TMC_USAGE_AMT = 0
TMC_USAGE_MAC = 0
Call DLF_USAGE_AMT_MARCY
End Sub
 
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
Need help with Application.WorksheetFunction Ayo Excel Discussion (Misc queries) 4 May 14th 08 11:13 PM
Application.WorksheetFunction._WSFunction R Avery[_2_] Excel Programming 0 May 13th 05 09:00 PM
Application.worksheetfunction Terry V Excel Programming 7 October 12th 04 05:48 AM
application.worksheetfunction.mmult help Alex[_13_] Excel Programming 2 October 29th 03 10:13 PM
Using Application.WorksheetFunction.Ln(...) in VBA doco Excel Programming 4 August 25th 03 01:08 PM


All times are GMT +1. The time now is 10:59 AM.

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"