Trouble Passing An Array

  • Thread starter Thread starter Kevin O'Neill
  • Start date Start date
K

Kevin O'Neill

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

------------------------------------------------------------------------------
 
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()
 
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
 
Back
Top