![]() |
Why does this produce an error?
Public Sub initialize() Dim NumberOfColumns As Integer NumberOfColumns = 13 Dim p(NumberOfColumns) As Integer end Sub Seems that Excel doesn't like using Variables to intialize arrays. How should this be done? -- zaphod2003 ------------------------------------------------------------------------ zaphod2003's Profile: http://www.excelforum.com/member.php...o&userid=34362 View this thread: http://www.excelforum.com/showthread...hreadid=541455 |
Why does this produce an error?
Hi
You need Public Sub initialize() Dim NumberOfColumns As Integer Dim p( ) as integer NumberOfColumns = 13 ReDim p(1 to NumberOfColumns) end Sub So you decare the array first with p( ) if you don't yet know the index range. Then you must ReDim it once the index range is known. regards Paul |
Why does this produce an error?
Hi,
And as the warning message says you can use a Const. Public Sub initialize() Const NumberOfColumns = 13 Dim p(NumberOfColumns) As Integer End Sub Or use the ReDim Public Sub initialize() Dim NumberOfColumns As Integer NumberOfColumns = 13 ReDim p(NumberOfColumns) As Integer End Sub Cheers Andy zaphod2003 wrote: Public Sub initialize() Dim NumberOfColumns As Integer NumberOfColumns = 13 Dim p(NumberOfColumns) As Integer end Sub Seems that Excel doesn't like using Variables to intialize arrays. How should this be done? -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info |
Why does this produce an error?
Thanks for your help much appreciated -- zaphod2003 ------------------------------------------------------------------------ zaphod2003's Profile: http://www.excelforum.com/member.php...o&userid=34362 View this thread: http://www.excelforum.com/showthread...hreadid=541455 |
All times are GMT +1. The time now is 03:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com