Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Passing Arrays Between Worksheet Functions

Hi,

I am trying to write some code which has an array to take values from one
worksheet and pastes them in another. I am trying to pass my array through
with no success. I keep getting type mismatch and various other errors.

This is the code:
Sub CollectData()

Dim Date_str(12, 12) As String
Dim Data_str As String
Dim Find_str As String
Dim ThisRow As Integer

Data_str = "Date"
ThisRow = ActiveCell.Row
Find_str = ActiveSheet.Cells(ThisRow - 1, 1).Value

Do Until Find_str = Data_str
ThisRow = ThisRow - 1
Find_str = ActiveSheet.Cells(ThisRow - 1, 1).Value
Loop

i = 1

For e = ThisRow To ThisRow + 11
Date_str(1, i) = ActiveCell.Value
Next

Call Sheet9.Order(Date_str)

End Sub

And the other sheet:
Sub Order(ByVal Date_str As String)

For i = 1 To 12
Date_str(1, i) = ActiveSheet.Cells(i, 1).Value
Next

End Sub

Any Help?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Passing Arrays Between Worksheet Functions

Try:

Sub Order(ByRef Date_str() As String)

You're passing an array--not a simple string and when you pass arrays, you have
to use byRef.



HJBEAN wrote:

Hi,

I am trying to write some code which has an array to take values from one
worksheet and pastes them in another. I am trying to pass my array through
with no success. I keep getting type mismatch and various other errors.

This is the code:
Sub CollectData()

Dim Date_str(12, 12) As String
Dim Data_str As String
Dim Find_str As String
Dim ThisRow As Integer

Data_str = "Date"
ThisRow = ActiveCell.Row
Find_str = ActiveSheet.Cells(ThisRow - 1, 1).Value

Do Until Find_str = Data_str
ThisRow = ThisRow - 1
Find_str = ActiveSheet.Cells(ThisRow - 1, 1).Value
Loop

i = 1

For e = ThisRow To ThisRow + 11
Date_str(1, i) = ActiveCell.Value
Next

Call Sheet9.Order(Date_str)

End Sub

And the other sheet:
Sub Order(ByVal Date_str As String)

For i = 1 To 12
Date_str(1, i) = ActiveSheet.Cells(i, 1).Value
Next

End Sub

Any Help?


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Passing Arrays Between Worksheet Functions

Try changing your Order procedure header to this...

Sub Order(ByVal Date_str() As String)

Note the empty parentheses telling the Order subroutine to expect a String
array.

--
Rick (MVP - Excel)


"HJBEAN" wrote in message
...
Hi,

I am trying to write some code which has an array to take values from one
worksheet and pastes them in another. I am trying to pass my array through
with no success. I keep getting type mismatch and various other errors.

This is the code:
Sub CollectData()

Dim Date_str(12, 12) As String
Dim Data_str As String
Dim Find_str As String
Dim ThisRow As Integer

Data_str = "Date"
ThisRow = ActiveCell.Row
Find_str = ActiveSheet.Cells(ThisRow - 1, 1).Value

Do Until Find_str = Data_str
ThisRow = ThisRow - 1
Find_str = ActiveSheet.Cells(ThisRow - 1, 1).Value
Loop

i = 1

For e = ThisRow To ThisRow + 11
Date_str(1, i) = ActiveCell.Value
Next

Call Sheet9.Order(Date_str)

End Sub

And the other sheet:
Sub Order(ByVal Date_str As String)

For i = 1 To 12
Date_str(1, i) = ActiveSheet.Cells(i, 1).Value
Next

End Sub

Any Help?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Passing Arrays Between Worksheet Functions

You can omit the ByRef keyword if you want as it is the default method of
passing arguments in VB.

--
Rick (MVP - Excel)


"Dave Peterson" wrote in message
...
Try:

Sub Order(ByRef Date_str() As String)

You're passing an array--not a simple string and when you pass arrays, you
have
to use byRef.



HJBEAN wrote:

Hi,

I am trying to write some code which has an array to take values from one
worksheet and pastes them in another. I am trying to pass my array
through
with no success. I keep getting type mismatch and various other errors.

This is the code:
Sub CollectData()

Dim Date_str(12, 12) As String
Dim Data_str As String
Dim Find_str As String
Dim ThisRow As Integer

Data_str = "Date"
ThisRow = ActiveCell.Row
Find_str = ActiveSheet.Cells(ThisRow - 1, 1).Value

Do Until Find_str = Data_str
ThisRow = ThisRow - 1
Find_str = ActiveSheet.Cells(ThisRow - 1, 1).Value
Loop

i = 1

For e = ThisRow To ThisRow + 11
Date_str(1, i) = ActiveCell.Value
Next

Call Sheet9.Order(Date_str)

End Sub

And the other sheet:
Sub Order(ByVal Date_str As String)

For i = 1 To 12
Date_str(1, i) = ActiveSheet.Cells(i, 1).Value
Next

End Sub

Any Help?


--

Dave Peterson


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
Returning arrays from custom worksheet functions in xll files JacksonRJones Excel Programming 0 March 22nd 06 05:47 PM
passing arrays to user defined functions ramki Excel Worksheet Functions 2 February 15th 06 08:34 AM
Linking worksheet functions and arrays - Doozie gsimmons2005 Excel Discussion (Misc queries) 1 August 17th 05 10:32 PM
Using Excel Worksheet functions in Arrays The Roon Excel Programming 1 January 13th 05 05:05 AM
passing arrays between functions in VBA Tom Ogilvy Excel Programming 3 March 1st 04 05:54 PM


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