Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ina ina is offline
external usenet poster
 
Posts: 120
Default passing argument in a function as integer problem

Hello Everybody,

I have this sub that display an array, I create a function that select
the correct range for my array. i have a problem to pass the argument
to the function

Sub displayArray()
Dim s(3, 3) As String
Dim arraysize, size, i As Integer
Dim rng_adrss, string1 As String

s(1, 0) = "A"
s(2, 0) = "B"
s(3, 0) = "C"

'rng_adrss this is the return string from my function
'size is the input of my function

size = 3

Debug.Print size

rng_adrss = selectRange(size)

Debug.Print rng_adrss

range(rng_adrss) = s

End Sub



Function selectRange(size As Integer) As String
Dim i, arraysize, j, h As Integer
Dim rowcell, newcolumn, salut, addr1 As String
Dim rng As range

arraysize = size

Debug.Print arraysize
Dim addr As String
addr = ActiveCell.Address


j = ColRef2ColNo(addr) ' return column number
h = j + arraysize
newcolumn = ColNo2ColRef(h) ' return column letter

rowcell = ActiveCell.Row
arraysize = arraysize + rowcell

Set rng = range(ActiveCell, newcolumn & arraysize)
addr1 = rng.Address

selectRange = addr1

End Function

my problem is that my function does not accepted my variable size tell
me that BYREF ARGUMENT TYPE MISTATCH

I do not know why?

Ina

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default passing argument in a function as integer problem

You dim statements are not doing what you think they are doing. Most of your
variables are of type variant. Check out Chip's site for more info...

http://www.cpearson.com/excel/variables.htm

This should fix up your problem...
--
HTH...

Jim Thomlinson


"ina" wrote:

Hello Everybody,

I have this sub that display an array, I create a function that select
the correct range for my array. i have a problem to pass the argument
to the function

Sub displayArray()
Dim s(3, 3) As String
Dim arraysize, size, i As Integer
Dim rng_adrss, string1 As String

s(1, 0) = "A"
s(2, 0) = "B"
s(3, 0) = "C"

'rng_adrss this is the return string from my function
'size is the input of my function

size = 3

Debug.Print size

rng_adrss = selectRange(size)

Debug.Print rng_adrss

range(rng_adrss) = s

End Sub



Function selectRange(size As Integer) As String
Dim i, arraysize, j, h As Integer
Dim rowcell, newcolumn, salut, addr1 As String
Dim rng As range

arraysize = size

Debug.Print arraysize
Dim addr As String
addr = ActiveCell.Address


j = ColRef2ColNo(addr) ' return column number
h = j + arraysize
newcolumn = ColNo2ColRef(h) ' return column letter

rowcell = ActiveCell.Row
arraysize = arraysize + rowcell

Set rng = range(ActiveCell, newcolumn & arraysize)
addr1 = rng.Address

selectRange = addr1

End Function

my problem is that my function does not accepted my variable size tell
me that BYREF ARGUMENT TYPE MISTATCH

I do not know why?

Ina


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 a Function name as a procedure argument [email protected] Excel Programming 9 November 7th 05 02:55 PM
problem passing an argument to a sub natanz Excel Programming 7 June 16th 05 08:45 PM
passing argument problem ?? ricksimm[_2_] Excel Programming 1 June 14th 05 12:30 AM
VBA - Passing a FUNCTION as an Argument James B Excel Programming 3 February 18th 04 03:42 PM
passing a variable as an argument to a function Drew[_6_] Excel Programming 3 July 25th 03 08:51 PM


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