ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Trouble Passing An Array (https://www.excelbanter.com/excel-programming/349628-trouble-passing-array.html)

Kevin O'Neill[_2_]

Trouble Passing An Array
 
I've tried to pass the array multiple times using different things, all
of which have returned a compile error. I'm not very familiar with VBA,
is what I'm doing correct? Way off?

Suggestions?

The first sub creates the array, the 2nd sub recieves it, and the 3rd
sub fires the first 2 arrays in order. I get the compile error on the
3rd sub.

------------------------------------------------------------------------------

Sub NewCalcSheet()
Dim ends(20) As Integer
Dim c2(5) As Integer
Dim ab

For d = Sheet11.Cells(18, 14).Value - 1 To 0 Step -1

'Large Amount of Code Left out
'Large Amount of Code Left out
'Large Amount of Code Left out

ends(ab) = Range("A50000").End(xlUp).Row
ab = ab + 1

Next d 'end stud loop

c() = ends()
ReDim Preserve c(Sheet11.Cells(18, 14).Value - 1)

Button38_Click c

End Sub

------------------------------------------------------------------------------

Sub Button38_Click(ByRef c())

End Sub

------------------------------------------------------------------------------

Sub CommandButton1_Click()

Sheet14.Select
CreateCalcSheetArray.NewCalcSheet 'Do Stuff "Calc Table"

Sheet11.Select
PrintArea.Button38_Click (c) 'COMPILE ERROR HERE

End Sub

------------------------------------------------------------------------------


Kevin O'Neill[_2_]

Trouble Passing An Array
 
Still no luck...


Kevin O'Neill[_2_]

Trouble Passing An Array
 
GOT IT!

Create
Button38_Click c()

Call
Dim po As Integer, dummy As Integer
For po = 1 To 2
dummy = c(po)
Next po

Call Functions
PrintArea.Button38_Click c()


Edward Ulle

Trouble Passing An Array
 
Keith,

Several things wrong that I can see.

First is it c or c2 you want to pass.

Second, you can not copy array by =.

Third, in CommandButton1_Click where does "c" come from?

I alway use Option Explicit to flush out variable name typos.

Ed



*** Sent via Developersdex http://www.developersdex.com ***


All times are GMT +1. The time now is 08:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com