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: 31
Default quick question

I have this macro (see below) which calculates commissions and fees using an
lot of If functions. Unfortunately the function seems to post a numberinto
the output columns a number even if the ticker (eg FLGH7) has not been
programmed into the macro. Is it possible to add to the macro some coding
which means the output will print 'ERROR' if the ticker in columns D is not
recognised?



Dim i As Integer
Dim j As Integer
Dim NumberOfTrades As Integer
Dim Fees As String
Dim Commissions As String

Range("M1") = "Clearing and Exchange Fees"
Range("N1") = "Execution Commissions"

NumberOfTrades = Application.CountA(Columns(4)) - 1


For j = 1 To NumberOfTrades

If Range("D1").Offset(j, 0) = "FLGH7" Then
Fees = "1.20"
Commissions = "0.55"
End If

If Range("D1").Offset(j, 0) = "FLGM7" Then
Fees = "0.98"
Commissions = "0.54"
End If


Volume = Range("F1").Offset(j, 0)

Range("D1").Offset(j, 9).Value = Fees * Volume
Range("D1").Offset(j, 10).Value = Commissions * Volume

If Range("D1").Offset(j, 0) = "FLGU7" Then
Fees = "0.96"
Commissions = "0.53"
End If

Next j

Columns("M:M").EntireColumn.AutoFit
Columns("N:N").EntireColumn.AutoFit

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
Quick little question ben simpson Excel Discussion (Misc queries) 3 April 11th 06 02:35 PM
Quick Question Nikki Excel Worksheet Functions 4 January 31st 06 02:51 PM
Quick Question Jenn Excel Discussion (Misc queries) 2 November 1st 05 09:20 PM
Quick question - quick answer about assigning shortcut keys funkymonkUK[_75_] Excel Programming 1 October 13th 05 10:50 AM
Quick Question??? hemants[_4_] Excel Programming 1 October 10th 04 02:06 PM


All times are GMT +1. The time now is 02:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"