Is there a way for the array range to be dynamic … like Dim array(1 to N) Double N could be set differently in different parts of the code?
Is there a way for the array range to be dynamic … like Dim array(1 to N) Double N could be set differently in different parts of the code?
Is there a way for the array range to be dynamic … like Dim array(1 to N) Double where N could be set differently in different parts of the code?
Paul ... please help me remember how to mark a topic “solved”
Above your first post, there's [Thread Tools] and an option is to mark [SOLVED]
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
Yes
Look in Help for "ReDim" and "Redim Preserve"
However, I've found that most times it's not needed and can be designed around
Some sample code
Option Explicit Sub Arrays() Dim A(1 To 2) As Long ' fixed Dim B() As Long ' ReDim-able A(1) = 100 A(2) = 200 MsgBox A(1) & " -- " & A(2) ReDim B(1 To 3) B(1) = 1000 B(2) = 2000 B(3) = 3000 MsgBox B(1) & " -- " & B(2) & " -- " & B(3) ReDim Preserve B(1 To 4) B(4) = 4000 MsgBox B(1) & " -- " & B(2) & " -- " & B(3) & " -- " & B(4) Erase A MsgBox A(1) & " -- " & A(2) A(1) = 10000 A(2) = 20000 MsgBox A(1) & " -- " & A(2) End Sub
---------------------------------------------------------------------------------------------------------------------
Paul
Remember: Tell us WHAT you want to do, not HOW you think you want to do it
1. Use [CODE] ....[/CODE ] Tags for readability
[CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
2. Upload an example
Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
3. Mark the thread as [Solved] when you have an answer
Thread Tools (on the top right corner, above the first message)
4. Read the Forum FAQ, especially the part about cross-posting in other forums
http://www.vbaexpress.com/forum/faq...._new_faq_item3
Paul ... thanks!