Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Calculating Commissions Macro

Just a quick question with regards my earlier post. I have managed to
combine my formula into a macro but am having a problem with the named
range I refer to. I am trying to get the last row (from column A) and
use it as a variable in the named range in column O. However it fails.
If I simply define the range (eg O8:O376) my code works fine. Any
ideas why it fails?

Also I'd like to apply the code only to cells in the renge CommRange
that are empty. That is for each cell, if empty then run the macro on
the cell ortherwise goto the next cell.

My code is below.

Thanks,

Richard


Sub Macro3()

Dim LastRow As Variant
Dim CommRange As Range

LastRow = Range("A" & Rows.Count).End(xlUp).Row
Range("O8", Range("O" & "LastRow")).Name = "CommRange"

Range("O8").Select
ActiveCell.FormulaR1C1 = _
"=MIN(3000,MROUND(IF(LEFT(RC1,1)=""4"",VLOOKUP(RC1 4,Agents!R1C1:R450C5,2,FALSE)+(VLOOKUP(RC14,Agents !R1C1:R450C5,3,FALSE)*RC6),VLOOKUP(RC14,Agents!R1C 1:R450C5,4,FALSE)+(VLOOKUP(RC14,Agents!R1C1:R450C5 ,5,FALSE)*R8C6)),0.01))"
Range("O8").Select
Selection.AutoFill Destination:=Range("CommRange"),
Type:=xlFillDefault
Range("CommRange").Select
ActiveWindow.SmallScroll Down:=-18
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End Sub
Reply
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
calculating commissions RC Excel Discussion (Misc queries) 3 July 22nd 09 12:21 AM
calculating commissions for a range of values abryan Excel Worksheet Functions 2 November 26th 05 06:01 PM
how to calculate commissions Peter Excel Worksheet Functions 6 November 5th 05 08:01 AM
Calculate commissions Pete Petersen Excel Worksheet Functions 6 November 17th 04 10:15 PM
Calculating Commissions Macro Steve Smallman Excel Programming 1 July 27th 03 05:16 PM


All times are GMT +1. The time now is 12:44 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"