Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Passing ranges to a subroutine

Friends,

I'm having trouble passing a range from one subroutine to another, and
I'd appreciate some help with my problem. In the main routine I write

Set Portfolio = ActiveWorkbook.Worksheets("Hedging").Range("C2",
Range("C2").End(xlDown))

I then call the subroutine fillIndex as follows:

Call fillIndex(Portfolio, "IG", IGCol, NIG, NIGInPort, lastRow, IG)

IGCol, NIG and NIGinPort are integers and IG is an array of length
NIG.


fillIndex is defined in the same module as follows:

Sub fillIndex(Portfolio As Range, CDXIndexName As String, Col As Long,
NHold As Long, IndexHoldingsinPort As Long, lastRow As Long,
Holdings() As Variant)
..
end sub

But when I try to execute it, the parameter NIG is consistently
highighted, and the following error message appears: ByRef Argument
type mismatch. What am I doing wrong, and how can I fix it?

Thanks in advance

Thomas Philips
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default Passing ranges to a subroutine

You wrote that NIG is an integer, but NHold is declared as Long....

HTH,
JP


On Mar 10, 11:06*pm, wrote:
Friends,

I'm having trouble passing a range from one subroutine to another, and
I'd appreciate some help with my problem. In the main routine I write

* * Set Portfolio = ActiveWorkbook.Worksheets("Hedging").Range("C2",
Range("C2").End(xlDown))

I then call the subroutine fillIndex as follows:

Call fillIndex(Portfolio, "IG", IGCol, NIG, NIGInPort, lastRow, IG)

IGCol, NIG and NIGinPort are integers and IG is an array of length
NIG.

fillIndex is defined in the same module as follows:

Sub fillIndex(Portfolio As Range, CDXIndexName As String, Col As Long,
NHold As Long, IndexHoldingsinPort As Long, lastRow As Long,
Holdings() As Variant)
.
end sub

But when I try to execute it, the parameter NIG is consistently
highighted, and the following error message appears: ByRef Argument
type mismatch. What am I doing wrong, and how can I fix it?

Thanks in advance

Thomas Philips


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
Passing reference to a checkbox to a subroutine. MikeAllgood Excel Programming 4 March 11th 08 06:27 AM
Passing Constant Arguments to custom Subroutine & Functions cLiffordiL Excel Programming 6 June 21st 06 09:17 AM
Passing Module to subroutine SixSigmaGuy[_2_] Excel Programming 2 April 25th 06 10:59 PM
Excel vba - passing a 3-dimensional array to a subroutine [email protected] Excel Programming 5 March 28th 06 07:50 PM
Passing arrays to a subroutine Braden Craig Excel Programming 4 August 17th 03 05:54 PM


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